We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13226
    • 953 Posts
    @Matt

    Cheers for the quick answer.

    Look forward to the end version with documentation or a small tutorial laugh

    Cheers for the good work
      • 18913
      • 654 Posts
      No prob. FWIW, the only problem I’ve found is with the recaptcha code itself, I think. If you enter two invalid words, you get an error. Fine. If you valid words, it works. Fine. But it seems that if you get only one of the words right it also works at times.

      I recall seeing a reference to this issue somewhere (not relative to MODx, I think) and will need to go track that down. Hopefully the issue is resolved.

      Working on the documentation/tutorial now, using as a base the updated eForm code you pointed to above.

      Matt
        • 18913
        • 654 Posts
        Here’s a mini-tutorial on how I adapted the eForm code to work with Recaptcha. This supercedes the code I referenced above and retains the ability to use the default Captcha code. I think (and dearly hope) this all works as advertised. If others could review, validate or otherwise point out issues, I’d be appreciative. The new code is attached.
        Matt

        - Create a folder for the recaptcha library, e.g.
        assets/snippets/recaptcha
        - Upload the recaptchalib.php file provided by recaptcha to the above folder
        - Upload the attached recapeform.inc.php to this folder as well
        - Put your private and public recaptcha keys in a file called recaptchakeys.php
        and upload it to this folder as well. It should look like this

        $publickey = "--your public key between these quotes--";
        $privatekey = "--your private key between these quotes--";
        


        - Create a copy of the eForm snippet, saving it as "recapeForm"
        - Edit this snippet, changing the name of the required include file from "eform.inc.php"
        to "recapeform.inc.php" and updating its location as well
        - The eForm function name has been changed in this include file to be "recapeForm". So
        change the original call to eForm to reflect this name change.
        - Create a document with the following content :

        [!recapeForm? &vericode=`2` &formid=`testform` &tpl=`testform_chunk` &report=`testformreport_chunk` &gotoid=`2`!]


        For no captcha, vericode = 0. For the default captcha, vericode = 1. For Recaptcha, vericode = 2.

        - In the chunk that defines the form to be used, add "[+captcha_html+]" in the place
        where the recaptcha image/dialogue is supposed to appear. The code for the form I used
        to test this is

        <p class="error">[+validationmessage+]</p>
        
        <form method="post" action="[~[*id*]~]" id="EmailForm" name="EmailForm">
        
        	<fieldset>
        		<h3> Test Form</h3>
        
        		<input name="formid" type="hidden" value="testform" />
        
        		<label for="cfName">Your name (required):
        		<input name="name" id="cfName" class="text" type="text" eform="Your Name::1:" /> </label>
        
        		<label for="cfEmail">Your Email Address (required):
        		<input name="email" id="cfEmail" class="text" type="text" eform="Email Address:email:1" /> </label>
        
        		<label for="cfMessage">Message (required): 
        		<textarea name="message" id="cfMessage" rows="4" cols="20" eform="Message:textarea:1"></textarea>
        		</label>
                </fieldset>
        
                   [+captcha_html+]
        
        		<label> </label><input type="submit" name="contact" id="cfContact" class="button" value="Send This Message" />
        </form>


        Notes :
        - I did not delete any code, but instead put my initials after or around anything
        I commented out or added. So to look for changes, search for "MattC"
        - The goal here was to avoid stomping on anything that is involved in the released
        version of eForm. So some of the above steps would not be needed if in fact one
        just wanted to replace eForm with this.
        - To allow for a more customized rendition of the recaptcha image, additional
        field subsitutions would need to be made, along the lines of the current manner
        in which "[+captcha_html+]" is inserted into the form. See lines 710-724. However,
        I have not actually tried doing this.
        - Not certain what if anything needs to be changed on lines 850-859 and line 998
        - When using the default Captcha I did get an "already submitted" message once. But
        I wasn’t able to reproduce the error, so I don’t know what happened there.
        - I’ve put up a demo at
        http://www.considine.net/recaptcha/
        No emails will actually get sent from the form, but you should be able to test out
        the logic of various types of entries.
          • 9290
          • 5 Posts
          Matt

          Thanks for doing this.

          The way reCaptcha works or the idea behind it is that you are helping to decode scanned books. One of the words in the code is from a scanned book that the OCR couldn’t recognize. Then they put it in reCaptcha’s database and send it out with another word image that is known. When a certain number/percentage of users decipher the unkown word’s meaning to be the same thing, they have solved their problem and added it to their database.

          So in essence, when you validate you only have to get one word right, the one that they know is already right.

          Hope this helps you so you don’t keep trying to solve an error that isn’t there.

          Explorertj
            • 18913
            • 654 Posts
            Explorertj -

            Ahh. That actually makes sense - one of the first things to do so today wink

            Thank you very much for your explanation.
            Matt
              • 38733
              • 22 Posts
              Scott M Sanders Reply #46, 12 years ago
              Would someone who has recapeform.inc.php.zip please re-upload it somewhere? The attachment here does not work. Thanks!
                • 38733
                • 22 Posts
                Scott M Sanders Reply #47, 11 years ago
                Year-later bump. No one?
                  • 5340
                  • 1,624 Posts
                  In case anyone still needs this
                    • 9995
                    • 1,613 Posts
                    thats a dead link too sad
                      Evolution user, I like the back-end speed and simplicity smiley