The amazing adventures of Doug Hughes

Comments Captcha'd

I took a few moments today and updated my blog comments page to use the Alagad Captcha Component. The process was quite simple. Because I use a highly customized version of Ray Camden’s Blog.cfc I won’t get into many details.

In a nutshell, I placed the Captcha Component into the application scope at startup. When a user accesses my comments page I call CreateCaptcha() to generate the Captcha image and related hash. This method returns a structure of information on the generated Captcha. I’ve elected to store the file name for the generated image and the hash in the user session.

The Captcha image is displayed on the comments form using an image tag pointing to a file named captchaImage.cfm. This file uses cfcontent to display and then delete the image based on the file name stored in session. A form field is displayed at this point to for the user to type in the text displayed.

When the user submits the form I again use the Captcha component stored in the application scope. This time I call it’s validate() method and pass in the hash stored in the session and the text provided by the user. If these match I know a human has filled out the form. If these do not match I send the user back to the form and ask them to try again.

Visit Alagad for more information on the Alagad Captcha Component.

Comments on: "Comments Captcha'd" (12)

  1. Doug Hughes said:

    This comment proves that the Captcha component works and that you can add comments!

    Like

  2. Joe Rinehart said:

    This is utter, shameless, self-promotion! I wholeheartedly approve!

    Like

  3. Tom Nunamaker said:

    I tried the trial but random characters are showing up as boxes. Any idea how to fix that?

    Looks like a cool tag if it can not display boxes instead of an alph-numeric character.

    Cheers

    Tom

    Like

  4. Doug Hughes said:

    Tom,

    The Captcha Component has tools to help you get around this. The problem stems from the fact that not all fonts have displayable glyphs for all characters.

    One way to approach this is to go though your font folder and find all of the fonts which do not have all of the alphanumeric glyphs. Note the name and create a list of bad fonts. You can this pass this list into the setIgnoredFontList() method which will prevent the component from using those fonts.

    Another way to take care of this is to dump the structure returned by the createCaptcha() method. This structure contains an array of font names used when creating the Captcha image. You can then compare the characters in your Captcha image against the array and determine which fonts are not displaying and use that information to create a list of bad font names to pass to setIgnoredFontList().

    At my earliest opportunity I will be adding more methods for font management. One of the best ideas Ive heard is a setAllowedFontList() method which will eventually allow you to pass a list of allowed font names.

    Thanks,

    Doug

    Like

  5. George Murphy said:

    Hi Doug, I am getting a tremendous amout of excess Captcha files on the server. How can I manage and delete these?

    Like

  6. I am also having trouble with an excess of Captcha files on the server. I didn’t see a response to the post by George Murphy regarding this. How do you delete these files?

    Like

  7. Hi
    I am also getting a massive number of images left on the server when the CFCONTENT tag does not delete the image that was served to the browser.

    Like

  8. http://concealer.mybrute.com
    Check out the cool little game

    Like

  9. boleho boleho

    Like

  10. adf d fasdf said:

    adfafafadfadfadfadfaf fdasf fas a dsf

    Like

  11. jkjkj

    Like

Comments are closed.

Tag Cloud