Compound Theory

v2.0

Categories

  1. Transfer
  2. ColdFusion
  3. Java
  4. ColdSpring
  5. Conduit
  6. JavaLoader
  7. ColdDoc
  8. AsyncHTTP
  9. OO Analysis and Design
  10. Flex
  11. Railo
  12. Hibernate
  13. ColdFusion Builder
  14. XML / XSL
  15. XHTML / CSS
  16. Ubuntu
  17. Eclipse
  18. Oracle Database
  19. Usability / UI Design
  20. cf.Objective()
  21. webDU
  22. cf.Objective(ANZ)
  23. Captcha
  24. MAX
  25. Melbourne CFUG
  26. Martial Arts
  27. Random Things

Recent Posts

Projects

Instant Message

Instantly grab my attention...

Recent Comments

20 January 2006 08:01 AM

Open Source CAPTCHA CFC v0.1 Released

Here is the initial release of my Captcha component .

It is a reworking of the code I use on this site to output my Captcha images, into a nice CFC that has two public methods -

The code here is pretty much 'as is'. The CFC should be relatively self explanatory, but I have provided examples in the zip file on how to use the CFC both ways.

If you have any feedback, feel free to send me an email .



Comments

Posted by Brian Rinaldi on 20 January 2006 08:13 AM

Great. Added to the open-source project list http://www.remotesynthesis.com/blog/index.cfm/2005/11/1/ColdFusion-OpenSource-Project-List

Posted by Peter J. Farrell on 20 January 2006 10:39 AM

Looks very interesting...can't wait to try it out.

Posted by Derek on 22 January 2006 02:44 PM

when using the cfcontent one, I get a strange issue. I tries to save the file as a .cfm when i go to the page to preview it. I think it has to do with the MIME type ..

Posted by Derek on 22 January 2006 02:46 PM

found the problem, your type needs to be image/jpeg not jpg.

Posted by Mark on 23 January 2006 08:34 AM

Derek,
If you look in the examples, you will see that the type set on the cfcontent tag is 'image/jpg'.

Let me know if you run into any other issues.

Posted by Meikel on 24 January 2006 05:49 AM

When using the cfcontent one, the image isn't resolved.
You can edit the source code and see:
<img src="captcha.jpg">
<br/><br/>
<img src="cfcontent.cfm">

Do I need cf 7.0? I tried it wit CF 6.1.

Thank you

Meikel

Posted by Derek Perez on 24 January 2006 08:59 AM

No no, just change the type="image/jpg" to "image/jpeg" it was a typo, you need the "e" (for iis 6 at least).

Posted by Derek Perez on 24 January 2006 11:30 AM

hey! I added you to wikipedia:
http://en.wikipedia.org/wiki/Captcha

there is a list of coldfusion Captcha components, i added you to the list :) hope you don't mind!

Posted by Mark on 24 January 2006 05:04 PM

Oh My G-d.

I'm so sorry Derek.. I didn't read your post properly.

You are totally correct in your statement about the mime type.

I've updated the example, and am uploading it now.

And of course I don't mind you added me to the Wiki, totally cool.

Thanks, mate.

Posted by Ryan K on 25 January 2006 04:04 AM

Nice...I'll have to check it out. I actually found you from the wiki, which looks like you were just added today. How's that for results?

I'll bring up your captcha project in our MMUG meeting tomorrow.

Posted by Peter J. Farrell on 25 January 2006 09:05 AM

Mark,

BTW, the writeToStream() is missing two var'ed variables - encode and ecodeParam. This might create some threading problems.

Best,
.Peter

Posted by Meikel on 26 January 2006 02:33 AM

Hi,
I changed the code to: <cfcontent type="image/jpeg" variable="#binary#">
but the image isn't shown. I always get the small red cross and the
coldfusion statement in index.cfm: <img src="cfcontent.cfm"> isn't replaced with the image. What's wrong?

Thank you for your help

Meikel

Posted by Mark on 26 January 2006 05:24 AM

Peter -

You are totally correct, looks like I missed that one. I've fixed it and re-uploaded the code.

Mekel - What happens when you access cfocntent directly? What browser are you using? What version of CF?

Posted by Meikel on 26 January 2006 09:08 PM

Hi Mark,
here is the error:
Attribute validation error for tag CFCONTENT.
The tag does not allow the attribute(s) VARIABLE. The valid attribute(s) are DELETEFILE,FILE,RESET,TYPE.

The error occurred in E:\Inetpub\wwwroot\captcha\cfcontent.cfm: line 37

35 : </cfscript>
36 :
37 : <cfcontent type="image/jpeg" variable="#binary#">


Thank you

Meikel

Posted by Meikel on 26 January 2006 09:13 PM

Sorry,
I forgot:
CF: 6.1,
Browser Internet Explorer 6, Mozilla, Netscape 7.1

Greetings

Meikel

Posted by Mark on 27 January 2006 04:34 AM

I should have noted somewhere that the variable attribute is only available in CF7. Sorry, I only just realised.

For CF6.1, you will have to write the captcha out to a file, or you can experiment with pushing the bytes out the response.getOutputStream() like so:

http://weblogs.macromedia.com/cantrell/archives/2003/06/using_coldfusio.cfm

I found there were issues doing that with the JpegEncoder lib in CF7, I'm not sure if they exitst in CF6.1.

Posted by Meikel on 30 January 2006 02:40 AM

Thank you very much

Great Job!!!

Meikel

Posted by David on 02 February 2006 09:26 AM

Is there a way to limit the set of fonts that are used?

Posted by Mark on 03 February 2006 12:22 PM

David -

There is currently no way of explicitly setting the fonts to be used without editing the underlying code.

The Captcha grabs a lists of the fonts that are available on the computer, and selects one at random to display the next character. If the next character can be displayed with the given font, it will use it, otherwise it will keep searching for the next font that can display the given character.

That's pretty much it.

Posted by vivek on 09 March 2006 11:03 PM

Attribute validation error for tag CFCONTENT.

I am using captcha for image genrated with random text but Second image is not showing up.

can you give the suggestion to work out this issue.

I saw above comments and follow some instruction also but it doesnt work out for me.
i used this solution also
35 : </cfscript>
36 :
37 : <cfcontent type="image/jpeg" variable="#binary#">

Please help me...

vivek

Posted by Jason Sheedy on 28 March 2006 08:32 PM

Hi Mark, looks interesting. I'll give it a go. cheers

Posted by John Igham on 07 April 2006 07:15 AM

I was trying to get the cfscript, below, to be more reactive to the length of the words I am using but I am not able to get it working, the error is:

Unable to find a constructor for class java.awt.Dimension that accepts parameters of type ( java.lang.Double, java.lang.String ).

The code is here:

<cfset c_word_list = "Pir8te,Hoists,Ballest,Flogger,Captain, Planker,Leeward">
<cfset c_word_day = DayOfWeek(now())>
<cfset captcha_word = ListGetAt(c_word_list, c_word_day)>
<cfset c_word_length = len(captcha_word)>
<cfset x = c_word_length * 35>

<!--- <cfabort> --->


<cfscript>
//create the captcha cfc (could be singleton)
captcha = createObject("component", "captcha").init();

//push to a file
captcha.captchaToFile(expandPath("captcha.jpg"),
'#captcha_word#',
#x#,
50,
30,
10,
35,
45,
60);
</cfscript>

If replace x with 350 all is well but ai do not have control over the width.

I am sure it is some thing simple I am missing because I was so easily able to implement my word var list.

Any leads would be appreciated...

John



Posted by Mark on 10 April 2006 09:19 AM

John,

Sorry for the late reply.

Looks like you will need to run a JavaCast("int", x) to make sure it comes through the right type. This should be something I should do inline within my CFC, but obviously missed. I'll keep this in mind for the next version.

Posted by Peter J. Farrell on 12 April 2006 04:41 PM

Don't mean to be spamming your blog Mark, but I thought I would mention that I release an open source CAPTCHA called LylaCAPTCHA today. Available at lyla dot maestropublishing dot com or you can click my name above and it should take you there.

Thanks Mark for letting me base my Captcha on yours. Your blessing meant a lot.

Posted by otnateos on 13 July 2006 12:56 PM

great work, combining Java & CF. I like the simplicity. cheers

Posted by Coulouvrat on 23 November 2006 04:31 AM

how can I define a fixed font instead of a random in the following line?
>>setNewFont(graphics, allFonts, size, arguments.shearXRange, arguments.shearYRange)

Posted by Mark on 23 November 2006 10:27 AM

You could simply remove the calls to setFont, and set the font you want to the graphic before all the calls are made.

If you want something more configurable, you should probably look at lylaCaptcha

Posted by steve on 03 January 2007 12:09 PM

6.1:
<cfcontent type="image/jpeg">
<cfoutput>#toString(binary)#</cfoutput>

Posted by Farrah on 12 January 2007 02:06 AM

Hi,
I am at point where I am ready to pull my hairs out. I am using version 6.1 and ofcourse the 2nd image doesn't get displayed.
I tried this from Steve's last comment:
<cfcontent type="image/jpeg">
<cfoutput>#toString(binary)#</cfoutput>

But this doesnt work either. Please can anyone help me with this??? Anyone has implement is successfully with 6.1??

I appreciate any help.

Posted by vijay on 03 February 2007 12:29 AM

Good one

Posted by Rodney L. Bickham on 08 March 2007 03:53 AM

How do you apply this cfc, its not clear from the contents of the zip file, a step by step for newbies would be nice.

Posted by Mark on 08 March 2007 09:27 AM

Rodney - I would suggest looking at lylaCaptcha. You can get the URL from the comments in this blog post, or by google.

Posted by Fabian on 07 May 2007 08:18 AM

Thanks a bunch for the CFC.
You saved my Ass :-)

Posted by Joel on 30 May 2007 05:52 AM

Very Nice.

Posted by Joel on 30 May 2007 05:55 AM

But, your implementation on this page has an easy work around.

Posted by Haseeb Khan on 07 June 2007 04:55 AM

Hi All,

I am also having issues with configuring CAPTCHA CFC on ColdFusion 6. I also tried LylaCaptcha but no luck as well. No image is displayed at all.

I am a beginner in ColdFusion. The LylaCaptcha also don't have a step-by-step guide for beginners like me.

It would be great if some step-by-step guide is provided for newbies like me so that we can benefit from this wonderful component as well.

Any help would be highly appreciated.

Thanks and Regards,

Haseeb Khan

Posted by Farrah Omar on 07 June 2007 06:33 AM

Haseeb,

I had the same problem with ColdFusion and I was never able to make it work. But I used this instead and it worked just fine: http://www.opensourcecf.com/imagecfc/.
Let me know if you need any help with this.

Posted by Farrah Omar on 07 June 2007 06:33 AM

* I meant same problem with ColdFusion 6.

Posted by Haseeb Khan on 07 June 2007 03:26 PM

Hi Farrah,

Thanks a LOT for your input. I have downloaded ImageCFC but I don't know how to make it work.

Is it possible that you can point out a step-by-step guide for configuring CAPTCHA using ImageCFC. I am very new to ColdFusion.

What I know is that CAPTCHA string should be unique everytime the user refreshes a page, but in the example of CAPTCHA at ImageCFC shows the same image even if the screen is refreshed. So, I am confused about its functionality.

My GTalk is mhaseebkhan@gmail.com. Can you please add me on your GTalk or send me your E-Mail on the above E-Mail address so if possible we can have a chat over the IM. I will be obliged.

Thanks and Regards,

Haseeb Khan

Posted by kurt schroeder on 23 June 2007 02:58 AM

I really owe you thanks for posting this system. i may like to create the same type of system for dot.net 2.0. However, i'd need to borrow the logic from your code to do so. I need the same type of symple functionality in a server control/w a perhaps a captcha class (dot.net)
Thanks!!!
KES

Posted by Joel on 07 August 2007 10:54 PM

I am having difficulty with the captcha image in IE 6.0. For example, when a user incorrectly enters the code, they are re-presented with the form they just filled out. However, in IE 6.0, the captcha image does not change, even though the hidden field I am testing it against does. Any idea on why this is happening? It works as expected in Firefox.

Thanks for this extremely helpful code. You have saved me from a lot of spam!

Posted by Mark on 08 August 2007 09:20 AM

@Joel - sounds like IE is caching the image, try putting a random number string at the end after a ?, should solve the problem.

Posted by Joel on 10 August 2007 01:21 AM

Mark--

Thanks for the suggestion. It works brilliantly!

Add Comment