Features
CFX_CAPTCHA 2.0 is packaged with a few additional attributes to help enhance the effectiveness of your CAPTCHA images. The BLUR, ALPHA, GRID & ROTATION attributes
are available to add layers of protection against increasingly intelligent robots.
EXAMPLES
Basic
<cfx_CAPTCHA OUTPUTFILE = "C:wwwrootmysitecaptcha.jpg">
<cfset returnText = CAPTCHAText> <!--- store returned random text --->
<img src="captcha.jpg" />
<cfif form.captcha neq returnText>
<cfoutput>You did not correctly enter the text in the CAPTCHA image.</cfoutput>
</cfif>
Advanced
<cfx_CAPTCHA OUTPUTFILE = "C:wwwrootmysitecaptcha.jpg"
TEXT = "Type this"
FONTSIZE = "32"
FONTFACE = "Arial"
FONTCOLOR = "FF0000"
FONTSTYLE = "bold"
BGCOLOR = "aa0000"
GRADIENTBGCOLOR1 = "ff0000"
GRADIENTBGCOLOR2 = "770000"
ALPHA = "50"
BLUR = "true"
GRID = "true"
GRIDCOLOR = "333333"
GRIDSPACING = "25"
ROTATION = "3">
<img src="captcha.jpg" />
<cfif form.captcha neq "Type this">
<cfoutput>You did not correctly enter the text in the CAPTCHA image.</cfoutput>
</cfif>
Installing CFX_CAPTCHA
1.) Copy the CAPTCHA.class file into your ColdFusion -> CFX -> java folder. On Windows, this folder is usually located at:
C:CFusionJavaclasses or C:CFusionMXcfxjava
2.) Go to ColdFusion Administrator in your web browser, then click on CFX Tags (under Extensions)
3.) Click Register Java CFX
4.) For Tag Name, type: CFX_CAPTCHA For Class Name, type: CAPTCHA
5.) Submit Changes
6.) You may need to restart your ColdFusion server for the changes to take effect
DOCUMENTATION
Return Variables
CAPTCHAMessage
Contains any errors generated by the tag, or "OK" if everything completed successfully.
CAPTCHAText
Contains the text generated in the CAPTCHA (if text is randomly generated).
Syntax
<cfx_CAPTCHA OUTPUTFILE = "string"
TEXT = "string"
TEXTLENGTH = "integer"
FONTFACE = "string"
FONTSIZE = "integer"
FONTCOLOR = "hexadecimal integer"
FONTSTYLE = "string"
BGCOLOR = "hexadecimal integer"
GRADIENTBGCOLOR1 = "hexadecimal integer"
GRADIENTBGCOLOR2 = "hexadecimal integer"
ALPHA = "integer"
BLUR = "boolean"
GRID = "boolean"
GRIDCOLOR = "hexadecimal integer"
GRIDSPACING = "integer"
SWIRL = "integer"
ROTATION = "integer">
Note: Make sure that you place quotation marks around all attributes, including integer and boolean attributes.
Attributes
OUTPUTFILE
Required. The absolute path to the CAPTCHA image that is output by cfx_CAPTCHA.
Valid File Types: jpeg and png
Unix Example: OUTPUTFILE = "varwwwmysiteimagesmycaptcha.jpg"
Windows Example: OUTPUTFILE = "C:inetpubwwwmysiteimagesmycaptcha.jpg"
TEXT
[Default = random]
Optional. The text used to generate the CAPTCHA image.
Example: TEXT = "Type this"
TEXTLENGTH
[Default = 5]
Optional. Used only when TEXT is empty. The length of the randomly generated text.
Example: TEXTLENGTH = "10"
FONTFACE
[Default = Arial]
Optional. The font face associated with the TEXT.
Note: The availability of font faces will vary depending on your server. Common fonts are Arial, Courier, Times New Roman and Verdana.
Example: FONTFACE = "Times New Roman"
FONTSIZE
[Default = 64]
Optional. The font size associated with the TEXT.
Example: FONTSIZE = "32"
FONTCOLOR
[Default = 555555 (grey)]
Optional. The hexadecimal equivalent of the RGB color associated with the TEXT. If you are unfamiliar with hexadecimal colors, http://www.december.com/html/spec/color.html offers help choosing the right hex value.
Example: FONTCOLOR = "FF0000"
FONTSTYLE
[Default = Plain (no style)]
Optional. The font style associated with the TEXT.
Values: bold, italic, both
Example: FONTSTYLE = "bold"
BGCOLOR
[Default = EEEEEE (light grey)]
Optional. The hexadecimal equivalent of the RGB background color for the CAPTCHA image. If you are unfamiliar with hexadecimal colors, http://www.december.com/html/spec/color.html offers help choosing the right hex value.
Example: BGCOLOR = "FF0000"
GRADIENTBGCOLOR1
[Default = BBBBBB (medium grey)]
Optional. The hexadecimal equivalent of the RGB background gradient starting color.
Example: GRADIENTBGCOLOR1 = "550000"
GRADIENTBGCOLOR2
[Default = EEEEEE (ligh grey)]
Optional. The hexadecimal equivalent of the RGB background gradient ending color.
Example: GRADIENTBGCOLOR2 = "AA0000"
ALPHA
[Default = 100]
Optional. Determines the transparency of the TEXT. A value of 100 is fully opaque (no transparency). A value of 0 is completely transparent.
Values: 0 to 100
Example: ALPHA = "50"
BLUR
[Default = false]
Optional. If true, adds a small amount of blur to the TEXT.
Example: BLUR = "true"
GRID
[Default = true]
Optional. Determines whether or not to add a grid of lines to the CAPTCHA image.
Example: GRID = "false"
GRIDCOLOR
[Default = 000000 (black)]
Optional. The color of the lines that make up the grid. Only applies if GRID is set to true.
Example: GRIDCOLOR = "AA00BB"
GRIDSPACING
[Default = 15]
Optional. Determines the spacing (in pixels) between adjacent lines in the grid. Only applies if GRID is set to true.
Example: GRIDSPACING = "25"
SWIRL
[Default = 0]
Optional. Determines the amount of swirl applied to the TEXT. Use this attribute with caution.
Due to the complex rendering algorithm applied, the resulting image may sometimes be difficult to read if the FONTSIZE is larger than 64 or the length of the text is longer than 8 characters.
Values: 0 to 4
Example: SWIRL = "2"
ROTATION
[Default = -5]
Optional. The amount of rotation (in degrees) to apply to the TEXT.
Values: -5 to 5
Example: ROTATION = "3"