css

Wednesday, May 5, 2010

Lyla Captcha and coldfusion 9

If you need to have a compatible script for captcha (e.g. running the script on a coldfusion mx server and on a coldfusion 8 and above server). You might be interested in the following solution i have used. First of all Lyla captcha is not compatible with coldfusion version 9 (haven't tested it on coldfusion 8 but i think it isn't compatible). As of coldfusion version 8 there is a cfimage tag which isn't compatible with coldfusion mx. To get a captcha script to work on both coldfusion mx and coldfusion 9 you can try the following.


<cfif left(server.coldfusion.productversion,1) gte 8>
<cflocation url="captcha-cf8.cfm">
<cfelse>
#Your Lyla captcha code here
</cfif>

The captcha-cf8.cfm file:
<cfset captchaimagepath=" getdirectoryfrompath(getcurrenttemplatepath())">

<cfimage fonts="Arial black" difficulty="medium" 
destination="#captchaimagepath#" text="12345" height="60" 
width="192" action="captcha">

<cfcontent deletefile="yes" file="#captchaimagepath#" 
type="image/png" reset="yes">

No comments: