[Pro] ReCaptcha

Hi everyone,
I need to add the Google ReCaptcha function to a page that uses the freeway php form action but I’m a total noob at adding code lines and markup items. Is there an easy way to do this?
Thanks in advance

Marcel


freewaytalk mailing list
email@hidden
Update your subscriptions at:

According to this page: reCAPTCHA v2  |  Google for Developers you can do this in two lines of code. First, though, you have to sign up and get your site key. This will require that you register the actual domain where you plan to use the captcha, This also means that it won’t work when you preview locally or view in a browser on your Mac, only when it is served from the same domain where your key is registered. You will need a separate key for each different site you build, assuming they have different domains. I’m assuming you want to use the v2 form of this, as v3 is still in beta, subject to change.

To begin (after signing up and getting your key) open the Page / HTML Markup dialog on the same page as your form. Change to the Before section of the dialog, and paste in this line:

<script src="https://www.google.com/recaptcha/api.js" async defer></script>

Okay and close the dialog.

Inside your form, say, before the Submit button, ensure that the text cursor is flashing and choose “Insert / Markup Item” from the main menu. A dialog will appear on screen. Paste in this code, editing the placeholder here for the actual site key you received when you signed up with Google:

<div class="g-recaptcha" data-sitekey="your_site_key"></div>

Okay the dialog. You will see a little [< H >] inline in the form. That box will be replaced with the recaptcha. Make sure it’s the only thing on the same line of text, and has room to display at its full size (other elements will be displaced by it, as if it was an inline image).

That should be enough to get it working. If you need more styling help, post a link to the working form, and someone here can guide you through adding some CSS or rejigging the page.

Walter

On Jul 30, 2018, at 8:19 AM, dadooper email@hidden wrote:

Hi everyone,
I need to add the Google ReCaptcha function to a page that uses the freeway php form action but I’m a total noob at adding code lines and markup items. Is there an easy way to do this?
Thanks in advance

Marcel


freewaytalk mailing list
email@hidden
Update your subscriptions at:
Information for existing FreewayTalk / Groups.io users - Site Feedback - Softpress Talk


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

Thanks Walt…going to give it a try


freewaytalk mailing list
email@hidden
Update your subscriptions at:

Works great, thanks for the help and the clear instructions


freewaytalk mailing list
email@hidden
Update your subscriptions at:

Oops, found one issue.
Form can be send without checking the ‘I’m not a robot’ box?
any ideas…?


freewaytalk mailing list
email@hidden
Update your subscriptions at:

You’d have to look at the Google documentation, I’ve never used this before. Google uses the results of the I’m not a Robot form element to feed their image recognition and self-driving cars, so they have a strong incentive to require it everywhere they can.

Walter

On Aug 6, 2018, at 8:32 AM, dadooper email@hidden wrote:

Oops, found one issue.
Form can be send without checking the ‘I’m not a robot’ box?
any ideas…?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
Information for existing FreewayTalk / Groups.io users - Site Feedback - Softpress Talk


freewaytalk mailing list
email@hidden
Update your subscriptions at:
https://freewaytalk.softpress.com/person/options

Did you find a simple solution to this?

I am trying the same integration. The reCaptcha displays fine but message is sent without ticking the box.
I am going nuts watching all the YouTube tutorials as none of them tells me how to do it in Freeway.

Please help me if you can!
Sverker


freewaytalk mailing list
email@hidden
Update your subscriptions at:

Hi Marcel,

An updated version of the Send Form Action along with some instructions can now be found on the knowledge base at Adding Google reCAPTCHA to your contact forms using the Send Form Action - Freeway - Softpress Talk

Simon


freewaytalk mailing list
email@hidden
Update your subscriptions at:

Yes, I got it to work, though it was a bit tedious. If you have come as far as the reCaptcha (v2) displaying you only need some simple code.

a) The PHP Feedback Form Action generates php file. If not, you need to set that up in Freeway; under Page / Form Setup. Set the Action attribute to “e-post-go.php” and the Method to POST (that’s what mine is called).

b) Then publish, a file with that name will be generated in the root of your local site folder. Now you deactivate (or delete) the PHP Feedback Form Action to prevent Freeway from overwriting it again.

I then moved the e-post-go.php to a separate folder and linked it to be uploaded automatically with the Upload Extra Resources Action.

c) I then opened the e-post-go.php file, (I use TextWrangler, BBEdit, or TextMate), and added the following lines of code at the top of file, under the initial command <?php

//The following lines of code integrates the Google ReCaptcha. You need to copy and paste your own secret key into the code below. You can edit the response messages to your liking below (under echo)

$email;$comment;$captcha;
    if(isset($_POST['email'])){
      $email=$_POST['email'];
    }if(isset($_POST['comment'])){
      $email=$_POST['comment'];
    }if(isset($_POST['g-recaptcha-response'])){
      $captcha=$_POST['g-recaptcha-response'];
 	 	unset($_POST['g-recaptcha-response']);
    }
    if(!$captcha){
      echo '<h2>You need to mark the reCaptcha box!</h2>';
      exit;
    }
    $secretKey = "PLACE-YOUR-SECRET-KEY-HERE";
    $ip = $_SERVER['REMOTE_ADDR'];
    $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
    $responseKeys = json_decode($response,true);
    if(intval($responseKeys["success"]) !== 1) {
      echo '<h2>SPAMMER! @$%K Off!</h2>';
    } else {
      echo '<h2>Thanks for your message.</h2>';
    }

//End of Captcha integration

You have to remember to edit this very copy of the file for any modifications, as it will overwrite whatever is on your server automatically whenever you publish and upload.

This should work (as far as I can remember).
Good Luck!


freewaytalk mailing list
email@hidden
Update your subscriptions at:

It’s worth noting that in that code, the message “SPAMMER! @$%K Off!” might be shown to a person if they fail the reCAPTCHA and submit anyway. I haven’t checked if that’s true but it’s undefined so if it’s not true today, it could be tomorrow without making any changes yourself.

It also doesn’t stop processing at that point, so in the case of a person failing the reCAPTCHA and submitting anyway or a bot submitting garbage including the g-recaptcha-response field, that SPAMMER message will appear before continuing with the rest of the script, presumably sending the email.

It’s also worth noting that verifying the recaptcha is done using a GET request. This must work since you’ve used it there but the documentation only talks about using a POST request, so it may stop working at any moment. Or it may work forever.

Simon


freewaytalk mailing list
email@hidden
Update your subscriptions at: