chronoforms with recaptcha

tommyhome 21 Mar, 2008
Hi,

I would love to know how to integrate chronoforms with recaptcha.

best regards,
Tommy, Sweden.
johnnyl 29 Mar, 2008
If anyone has figured out the code modifications which need to be done to use recaptcha, I would be interested in seeing them here...

I would like to try it out, but don't have the time to spend hacking around right now. So if anyone else has already done it and doesn't mind sharing, that would be great!
steveharman 31 Jan, 2009
Seconded! This would be incredibly useful, for ChronoForms as a product and us as users.

I'm happy to have a go and will post my findings / instructions here if I get things to work, if someone could point me at the right file(s) to start looking at within ChronoForms please?

Thanks,

Steve
GreyHead 31 Jan, 2009
Hi steve, johnny and all,

I have reCaptcha working in ChronoForms - here's a test form, try as much as you like the form just submits and re-displays.

It's a bit of a mess so I'll clean the code up and then post it here. No core code hacks required.

Bob

PS It's on my site because the reCaptcha key is domain specific.

PPS I think it could be put in a ChronoForms PlugIn but that does need a core hack to let the Plugn run both on load and submit.
GreyHead 31 Jan, 2009
Hi all,

To use reCapcha with ChronoForms[list]
  • Sign up for reCaptcha and get Public and Private keys for your domain
  • Unzip and copy the attached chrono_recaptchalib.php file into your components/com_chronocontact folder
  • Add this code to your Form HTML where you want the reCaptcha to appear
    <?php
    include_once(JPATH_COMPONENT_SITE.DS.'chrono_recaptchalib.php');
    // you got this from the signup page
    $publickey = "###~~your public key~~###"; 
    echo "<div style='width:312px; height:125px;'>".recaptcha_get_html($publickey)."</div>";
    ?>
  • Go to the Validation Tab for your Form; enable Server Side Validation.
  • Go to the Anti-Spam tab andmake sure that imageverification is disabled.
  • Enter this code in the ServerSide Validation Code box
    <?php
    include_once(JPATH_COMPONENT_SITE.DS.'chrono_recaptchalib.php');
    $privatekey = "###~~your private key~~###";
    $resp = recaptcha_check_answer (
        $privatekey,
        $_SERVER["REMOTE_ADDR"],
        JRequest::getVar("recaptcha_challenge_field"),
        JRequest::getVar("recaptcha_response_field") );
    
    if ( !$resp->is_valid ) {
      return "The reCAPTCHA wasn't entered correctly. Go back and try it again<br />
      (reCAPTCHA said: ".$resp->error.")";
    }
    ?>
  • Make sure that you have the correct reCaptcha key in each code block
  • [/list]
    Bob
    Max_admin 01 Feb, 2009
    Hi Bob,

    Thank you very much for posting this great tutorial🙂 I will copy it to the hacks forums and will add it to the next release or the next one!

    Best rgeards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    GreyHead 01 Feb, 2009
    Hi Max,

    Thanks, if you have a moment to add a little hack to the next release of ChronoForms I could easily create this as a PlugIn. We just need a third class of PlugIn that can be called both ONLOAD and ONSUBMIT

    Bob
    Max_admin 01 Feb, 2009
    Hi Bob,

    I can do this for sure, let me put the next release and call it RC1 when I finish the new wizard changes then make those new plugin changes in another RC😉

    Warm regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    Abhishka 27 Feb, 2009
    Hi Bob!

    Hope you are doing well. Well I am trying to install Re-Captcha. However, there is no Server Side Validation in Validation tab. And where to add the Code???

    Can you help me? I think I am very close, yet too far.

    Thanks
    Abhi
    GreyHead 27 Feb, 2009
    Hi Abhi,

    I forget that you are in an old version of ChronoForms. You will need to use one of the OnSubmit code boxes and then use showform() to re-display the form. If you search here on showform you should find the syntax OK.

    Bob
    Abhishka 12 Mar, 2009
    Hi Bob..

    I was able to use Re-captcha on regsitration page. But, I need for contact use form. not for registration.
    Now the GD support is enabled and i can see the images and other stuff in the Anti-Spam menu.

    Select the type of image to show ? With Fonts
    GD Version bundled (2.0.34 compatible)
    FreeType Support Yes
    PNG Support Yes
    Sample image: ( there is an sample image)

    Now that i know GD is working, why i can't see the imageverification image in FF as well as IE7???

    Regards
    Abhi
    Max_admin 12 Mar, 2009
    Hi Abhi,

    try to access the image file directly like this and tell me what you get:

    http://www.domain.com/components/com_chronocontact/chrono_verification.php


    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    stmoist 16 Mar, 2009
    Thanks for those easy-to-follow instructions, Bob! I kept getting a "Please Try Again" pink error box every time I submitted a form. I was going crazy until I realized I forgot to set the "Use Image Verification" to "No" in the "Anti Spam" tab!
    GreyHead 16 Mar, 2009
    Hi stmoist,

    Thanks for pointing that out - I've updated the instructions. Hopefully with the next release we can turn this into a ChronoForms Plugin if Max hasn't already built it in.

    Bob
    momentis 25 Mar, 2009
    Bob,

    I am very new to this extension, but I am already in LOVE with it! After too long struggling with RSForms, I decided to try this and I am so glad I did. Awesome, awesome tool!!! Thank you very much for the reCaptcha instructions - they worked perfectly, and now my client will be happy.

    All who have developed this extension should be very, very proud. No I'm going over to JED to give it kudos!

    Peace,
    Rick

    PS - I am using RC3, which does not include the reCaptcha plugin. No big deal (your instructions are great), but do you have an idea if this will be implemented in an upcoming release?
    GreyHead 25 Mar, 2009
    Hi Rick,

    Thank you - Max will be delighted to hear that you are so pleased with his work :-)

    The ReCaptcha PlugIn is written and working 98% - I didn't quite make it in time for the RC3 release but Max now has the code.

    The missing 2% is that in IE7 it sometimes (but not always) triggers an Operation Abandoned alert which has something to do with the sequence of JavaScript loading on the page. I don't think this is solely to do with the PlugIn but is a combination of factors that I haven't managed to bottom out yet :-(

    Bob
    momentis 25 Mar, 2009
    Great! Figures the issues lie with IE!!!

    Max - if you're listening - super work!
    Max_admin 25 Mar, 2009
    Hi Rick,

    Thank you, I'm trying to improve some issues in RC3 in the next 2 days then I will add a new release with the reCaptcha plugin written by Bob after giving it a test to see the IE7 issue myself and maybe I will be able to fix it!🙂

    Regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    mrsynock 26 Mar, 2009
    the code is wrong with mambot : I get a path error

    I have to turn
    JPATH_COMPONENT_SITE.DS.'chrono_recaptchalib.php' 


    to

    JPATH_ROOT.DS.'components/com_chronocontact/chrono_recaptchalib.php'


    only in "form code" not in "server validation code"

    If this can help others
    Max_admin 26 Mar, 2009
    Thanks for sharing! this will be tested when an official release is out!

    Regards
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    momentis 30 Mar, 2009
    No worry! If you look at the code that Bob posted:

    Hi all,

    To use reCapcha with ChronoForms[list]

  • Sign up for reCaptcha and get Public and Private keys for your domain
  • Unzip and copy the attached chrono_recaptchalib.php file into your components/com_chronocontact folder
  • Add this code to your Form HTML where you want the reCaptcha to appear
    <?php
    include_once(JPATH_COMPONENT_SITE.DS.'chrono_recaptchalib.php');
    // you got this from the signup page
    $publickey = "###~~your public key~~###"; 
    echo "<div style='width:312px; height:125px;'>".recaptcha_get_html($publickey)."</div>";
    ?>
  • Go to the Validation Tab for your Form; enable Server Side Validation.
  • Go to the Anti-Spam tab andmake sure that imageverification is disabled.
  • Enter this code in the ServerSide Validation Code box
    <?php
    include_once(JPATH_COMPONENT_SITE.DS.'chrono_recaptchalib.php');
    $privatekey = "###~~your private key~~###";
    $resp = recaptcha_check_answer (
        $privatekey,
        $_SERVER["REMOTE_ADDR"],
        JRequest::getVar("recaptcha_challenge_field"),
        JRequest::getVar("recaptcha_response_field") );
    
    if ( !$resp->is_valid ) {
      return "The reCAPTCHA wasn't entered correctly. Go back and try it again<br />
      (reCAPTCHA said: ".$resp->error.")";
    }
    ?>
  • Make sure that you have the correct reCaptcha key in each code block
  • [/list]
    Bob



    There are two areas where you'll insert the keys. In the first block, include your public key where it shows:
    $publickey = "###~~your public key~~###"


    And in the second block, replace the private key where you find:
    $privatekey = "###~~your private key~~###"


    Just make sure you leave the quote marks around your key. You're right - you are almost there! If you need any further help, I'd be happy to assist!

    Rick
    momentis 30 Mar, 2009
    Until someone more intelligent than I gets online, I'll do my best to confuse you😀

    Have you made sure that the "Use Image Verification" is set to "No" in the "Anti Spam" tab for the form?
    Does your sever have GD support enabled?

    That's about the extent of my help. Sorry! However, once Bob and/or Max gets online, you'll get much more appropriate help. I just try to give back where I can. Good luck with this!

    Rick
    Max_admin 30 Mar, 2009
    Hi all,

    @billdematte, please follow Rick's guidance now because I really didn't test this hack myself, Bob made a complete reCaptcha plugin, very clean solution but it will be out with the next release which I'm working at now and keeps me very busy because alot of users are waiting it.

    So my advise for now is to play with it till I put the new release online or may be Bob gives you an answer soon but I'm not sure when!

    Regards,
    Max
    Max, ChronoForms developer
    ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
    ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
    stmoist 02 Apr, 2009
    My forms with the reCaptcha plugin seem to have gone kaput (sample - http://nationalcsa.com/about-us/contact-us):
    Warning: include_once(/home/ncsac4pd/public_html/components/com_content/chrono_recaptchalib.php) [function.include-once]: failed to open stream: No such file or directory in /home/ncsac4pd/public_html/modules/mod_chronocontact/helper.php(319) : eval()'d code on line 158
    
    Warning: include_once() [function.include]: Failed opening '/home/ncsac4pd/public_html/components/com_content/chrono_recaptchalib.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ncsac4pd/public_html/modules/mod_chronocontact/helper.php(319) : eval()'d code on line 158
    
    Fatal error: Call to undefined function recaptcha_get_html() in /home/ncsac4pd/public_html/modules/mod_chronocontact/helper.php(319) : eval()'d code on line 161

    Were working fine last week!

    EDIT: I just copied chrono_recaptchalib.php to /com_content and it seems to work fine now. Why would it just pop up with that? I don't think I've changed any settings or upgraded anything...
    GreyHead 02 Apr, 2009
    Hi stmoist,

    It's because the link is realtive - it will work OK whilst the form is in com_chronocontact but when you use the Plugin or Module to put it on a content page it loses track. Sorry about that - but you found a good fix.

    Bob
    momentis 02 Apr, 2009
    Hey Bob,

    I heard you had written a slick little plugin for this. Has this been released, or will this still be out with the next release of CF?

    Rick
    GreyHead 02 Apr, 2009
    Hi Rick,

    Yes I have, it has a problem with IE7 - sometimes an Operation Aborted message gets triggered and the page won't load. This is something to do with the way the JavaScript loads into the page - combined I think with the remote loading of the ReCaptcha script :-(

    When I have a moment I'll see if I can debug it - I don't think it's a problem in the PlugIn itself but one of those 'combination' things. It also doesn't happen all the time - around 10-20% in my quick tests - so not obvious to debug.

    Bob
    momentis 28 May, 2009
    Bob/Max,

    Thanks a bunch for the plugin on this!

    Rick
    designso 28 Dec, 2009
    Hi, I'm having a similar issue to the one that stmoist had. I am running Joomla 1.0.13 and CF 2.3.9, but a 2.3.9 from April 14 of 2008. When I open the page with the form on it (http://designsolutionsusa.com/index.php?option=com_chronocontact&chronoformname=cad_quick_quote) I get the following:

    Warning: include_once(JPATH_ROOTDScomponents/com_chronocontact/chrono_recaptchalib.php) [function.include-once]: failed to open stream: No such file or directory in /hermes/web09/b2191/as.designso/public_html/components/com_chronocontact/chronocontact.html.php(74) : eval()'d code on line 182

    Warning: include_once() [function.include]: Failed opening 'JPATH_ROOTDScomponents/com_chronocontact/chrono_recaptchalib.php' for inclusion (include_path='.:/usr/local/lib/php-5.2.2/lib/php') in /hermes/web09/b2191/as.designso/public_html/components/com_chronocontact/chronocontact.html.php(74) : eval()'d code on line 182

    Fatal error: Call to undefined function recaptcha_get_html() in /hermes/web09/b2191/as.designso/public_html/components/com_chronocontact/chronocontact.html.php(74) : eval()'d code on line 185



    Now, as I am running an older vesion of CF, I do not have the Server Side Validation Code Box, so as you suggested I put the following code in the "On Submit code - before sending email" box:

    <?php
    include_once(JPATH_COMPONENT_SITE.DS.'chrono_recaptchalib.php');
    $privatekey = "6LeaGQoAAAAAAHw_MNl8D7llU5i8hzf2JJY7KtBF";
    $resp = recaptcha_check_answer (
    $privatekey,
    $_SERVER["REMOTE_ADDR"],
    JRequest::getVar("recaptcha_challenge_field"),
    JRequest::getVar("recaptcha_response_field") );

    if ( !$resp->is_valid ) {
    return "The reCAPTCHA wasn't entered correctly. Go back and try it again<br />
    (reCAPTCHA said: ".$resp->error.")";
    }



    The php file you attached is in the proper folder and I'm running out of ideas myself. Thanks for any help!
    Kate454 03 Aug, 2011
    I have been using Chronoforms for a little over and have been very satisfied with the functionality, stability, and tech support.
    Recently found chronoforms V4 - it is worth the effort to learn as it has power to make large tasks easy. V4 documentation is a bit thin at present but the forum is very well supported and I'm sure it will achieve exactly what I ask of it. V3 documentation is very complete so expect V4 to progress nicely.
    This topic is locked and no more replies can be posted.