Zen Cart Logo
Forums / All Other Contributions/Addons / Support Thread for Google reCAPTCHA plugin

Support Thread for Google reCAPTCHA plugin

Views: 176,342

Results 301 to 320 of 694
27 Feb 2018, 6:19 PM
#301
epilot avatar

epilot

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

Support Thread for Google reCAPTCHA plugin

Probably the last questions before the upgrade are below.

Google states in its reCaptcha installation instructions "Paste this snippet at the end of the <form> where you want the reCAPTCHA widget to appear:

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

The data-sitekey is the public key generated by Google for reCaptcha v.2.

Question1.
Do I need to paste the public key as stated by Google or the public key has already been integrated in the
/includes/functions/extra_functions/recaptchalib.php ?

Question 2.
If I need to paste the public key, where do I find the "form"? Is this the php file that defines "contact us" page?
Also, there are three pages on which reCaptcha will appear contact_us_default, create_account, and product_reviews. I assume that I will need to paste the public key in all of them. Please confirm.

Thank you very much.

27 Feb 2018, 6:49 PM
#302
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Support Thread for Google reCAPTCHA plugin

The plugin's readme (hint, hint) explicitly states:

Step 2
    Open the file /includes/functions/extra_functions/recaptchalib.php and insert the public and private keys you got in Step 1. They need to go on lines 9 and 10

Recording those values there enable the plugin to use your public/private keys in all pages.

27 Feb 2018, 7:27 PM
#303
epilot avatar

epilot

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

Re: Support Thread for Google reCAPTCHA plugin

Thank you. What you are stating is correct.

However, it does not adders the fact that Google provide separate 3 step instructions on how to integrate reCaptcha v.2 to a website. Step 1 of these instructions requires:

Paste this snippet at the end of the <form> where you want the reCAPTCHA widget to appear:

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

Hence I had a question - do I need to do what Gooogle states or this step has already been taken care of by the addon I am installing?

27 Feb 2018, 7:38 PM
#304
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Support Thread for Google reCAPTCHA plugin

epilot:

Thank you. What you are stating is correct.

However, it does not adders the fact that Google provide separate 3 step instructions on how to integrate reCaptcha v.2 to a website. Step 1 of these instructions requires:

Paste this snippet at the end of the <form> where you want the reCAPTCHA widget to appear:

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

Hence I had a question - do I need to do what Gooogle states or this step has already been taken care of by the addon I am installing?
It's already handled by the plugin.

27 Feb 2018, 9:48 PM
#305
epilot avatar

epilot

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

Re: Support Thread for Google reCAPTCHA plugin

Thank you. I transferred the files on the server. I experienced two problems.

Problem 1.
I have two captchas below my email form. One is the usual one with white background. The second one has a black background. I suspect that this is a result of manually inserting, as suggested in the read me file, the line

<?php echo recaptcha_get_html(); ?>

Or there may be another reason. At any rate, I would like to keep only one (white) captcha.

Problem2.
It has been several years since the email form was set up. I do not remember where I inserted the email address to which the email form sends the email from the website. Flowing my upload on the server, I lost the email form settings and I could not receive any emails form the website. Where is the file that sets up the email address for the email form on contact us page?

Thank you.

28 Feb 2018, 12:28 PM
#306
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Support Thread for Google reCAPTCHA plugin

You're most likely not receiving emails due to that double-capcha. Please post the section (including about 10 lines above and about 10 lines below) of your template modification around the line you inserted ... using the "CODE" tag (the big **# **in the posting menu-bar) to surround that code.

28 Feb 2018, 5:07 PM
#307
epilot avatar

epilot

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

Re: Support Thread for Google reCAPTCHA plugin

Here it is the code for the file tpl_contact_us_default.php

<label class="inputLabel" for="contactname"><?php echo ENTRY_NAME; ?></label>
<?php echo zen_draw_input_field('contactname', $name, ' size="40" id="contactname"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />

<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label>
<?php echo zen_draw_input_field('email', ($email_address), ' size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />

<label for="enquiry"><?php echo ENTRY_ENQUIRY . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?></label>
<?php echo zen_draw_textarea_field('enquiry', '30', '7', $enquiry, 'id="enquiry"'); ?>
<?php echo recaptcha_get_html(); ?>
<?php echo recaptcha_get_html($publickey, $resp->error,$request_type == 'SSL'); ?>

<?php echo zen_draw_input_field('should_be_empty', '', ' size="40" id="CUAS" style="visibility:hidden; display:none;" autocomplete="off"'); ?>

</fieldset>

<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_SEND, BUTTON_SEND_ALT); ?></div>
<div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div>
<?php
  }
?>
</form>
</div>
1 Mar 2018, 6:41 PM
#308
epilot avatar

epilot

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

Re: Support Thread for Google reCAPTCHA plugin

Still need assistance with this issue.

1 Mar 2018, 7:13 PM
#309
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Support Thread for Google reCAPTCHA plugin

Remove the line

<?php echo recaptcha_get_html(); ?>
1 Mar 2018, 10:42 PM
#310
epilot avatar

epilot

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

Re: Support Thread for Google reCAPTCHA plugin

Thank you.

I removed the line as you suggested. One (light) captcha has disappeared the second one (dark) remained. I still have two problems.

Problem 1.
The remaining captcha is dark and square.

Problem 2.
The email form still does not send emails.

Need help to fix this as time is running out to switch to captcha v2.

2 Mar 2018, 12:46 PM
#311
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Support Thread for Google reCAPTCHA plugin

OK, for number 1 (having, again read the readme file provided by the plugin): Replace the line <?php echo recaptcha_get_html(); ?>, removing the other one. The default "style" without arguments is the light-colored one, which is the styling you want.

For the "emails not sending", a couple of questions:

  1. Did your contact-us emails send before the change?
  2. When you click the "send" button from the contact-us page, do you receive a message that the email has been sent?
  3. Are there any myDEBUG*.log files present in your store's /logs directory? If so, try to send the contact-us message again and see if one is generated when you do that; post its contents if found.
  4. What is the value for your store's Configuration->Email Options->Set "Contact Us" Email Dropdown List?
2 Mar 2018, 8:26 PM
#312
epilot avatar

epilot

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

Re: Support Thread for Google reCAPTCHA plugin

Thank you.

I will remove the original line <?php echo recaptcha_get_html($publickey, $resp->error,$request_type == 'SSL'); ?>

and will replace it with the line <?php echo recaptcha_get_html(); ?>

  1. Yes, I have originally installed captcha plugin v.2.0 in 2012 and I have never had any problems with it since installation. I am reversing my files back to that version after each unsuccessful upgrade to Google captcha v.2. to allow customers to contact us and to register on the site.

  2. When I am using the original version of the plugin (v.2.0 that operates) after I click on the send button, the contact form disappears and a message "your message has been successfully sent" appears instead. When I am sending a message after the upgraded plugin (v.3.2 for Google captcha v.2 upgrade) is installed, clicking on the send button does not produce anything - the form remains there with all fields filled in and no message of any kind (errors or success) appears. Of course, nothing arrives into the dedicated email address.

  3. I have never used myDEBUG. I need your instructions on how to find it and how to use it.

  4. I am using Numinix email configuration plugin and Configuration->Email Options->Set "Contact Us" Email Dropdown List is an empty text box with nothing in it.

Thank you again. I will try to upgrade again after I receive your reply to this message.

2 Mar 2018, 8:35 PM
#313
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Support Thread for Google reCAPTCHA plugin

@epilot, thanks for the responses:

  1. That implies to me that either there's an HTML validation or javascript/jQuery error preventing the submission of the form.
  2. Look in your store's /logs directory (it's at the same "level" as your store's /includes directory) for files named myDEBUG*.log; they'll identify any PHP-related issues with the formatting.
  3. I'd asked about that setting because some stores have been having issues when that value is improperly formatted.

Do you have a publicly-available link you could share (either via direct forum posting or sent to me via PM)?

2 Mar 2018, 9:31 PM
#314
epilot avatar

epilot

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

Re: Support Thread for Google reCAPTCHA plugin

Thank you for the reply. I will send you a link via PM.

Now that you identified the myDEBUG's location, I recall that have used it in the past when I had issues with the site. I have several logs available related to the captcha update dated March 1 and March 2. How to send them to you? Can I do it via PM as well?

2 Mar 2018, 9:35 PM
#315
epilot avatar

epilot

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

Re: Support Thread for Google reCAPTCHA plugin

A PM was sent.

3 Mar 2018, 1:28 PM
#316
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Support Thread for Google reCAPTCHA plugin

@epilot, got your link. The captcha displayed looks like the older version. I was able to (I think) send you a test message, did you receive it?

Are you sure that you removed/replaced all the older captcha files with the updated version?

Regarding the debug-logs, find one that identifies an issue with the captcha and post its contents here, in the support thread, using "CODE" tags (the big **# **in the menu-bar when you write your reply).

3 Mar 2018, 2:46 PM
#317
epilot avatar

epilot

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

Re: Support Thread for Google reCAPTCHA plugin

@lat9 Got you test message, thank you. I had to reverse to the older version since the new version does not operate. Or you would not be able to send a test message.

I think I replaced all files of the older version. I read both READ ME files (for the original version and the version I am installing) and I saw that the new version should overwrite the older files as they have the same names.

Here is the debug file information.

[01-Mar-2018 17:05:13] PHP Warning:  file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /includes/classes/observers/google/ReCaptcha/RequestMethod/Post.php on line 68

[01-Mar-2018 17:05:13] PHP Warning:  file_get_contents(https://www.google.com/recaptcha/api/siteverify): failed to open stream: no suitable wrapper could be found in /includes/classes/observers/google/ReCaptcha/RequestMethod/Post.php on line 68

[01-Mar-2018 17:05:13] PHP Warning:  implode(): Invalid arguments passed in /includes/classes/observers/google/ReCaptcha/Response.php on line 128
3 Mar 2018, 3:12 PM
#318
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Support Thread for Google reCAPTCHA plugin

Since file_get_contents is not configured on your site for non-local files, you'll need to edit /includes/classes/observers/class.google_recaptcha.php. Find the section:

    function update(&$class, $eventID, $paramsArray = array()) {
        global $messageStack, $error, $privatekey;

        require_once __DIR__ . '/google/autoload.php';
        $recaptcha = new \ReCaptcha\ReCaptcha($privatekey);
        // If file_get_contents() is locked down on your PHP installation to disallow
        // its use with URLs, then you can use the alternative request method instead.
        // This makes use of fsockopen() instead.
        //$recaptcha = new \ReCaptcha\ReCaptcha($privatekey, new \ReCaptcha\RequestMethod\SocketPost());
        // This makes use of curl instead
        //$recaptcha = new \ReCaptcha\ReCaptcha($privatekey, new \ReCaptcha\RequestMethod\Curl());

        $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);

        if (!$resp->isSuccess()) {
            $event_array = array('NOTIFY_CONTACT_US_CAPTCHA_CHECK' => 'contact', 'NOTIFY_CREATE_ACCOUNT_CAPTCHA_CHECK' => 'create_account', 'NOTIFY_REVIEWS_WRITE_CAPTCHA_CHECK' => 'review_text');
            $messageStack->add($event_array[$eventID], $resp->getErrors());
            $error = true;
        }
        return $error;
    }

and change that as below, adding comments before the one line and removing the comments (//) from the other

    function update(&$class, $eventID, $paramsArray = array()) {
        global $messageStack, $error, $privatekey;

        require_once __DIR__ . '/google/autoload.php';
        [B]//[/B] $recaptcha = new \ReCaptcha\ReCaptcha($privatekey);
        // If file_get_contents() is locked down on your PHP installation to disallow
        // its use with URLs, then you can use the alternative request method instead.
        // This makes use of fsockopen() instead.
        //$recaptcha = new \ReCaptcha\ReCaptcha($privatekey, new \ReCaptcha\RequestMethod\SocketPost());
        // This makes use of curl instead
        $recaptcha = new \ReCaptcha\ReCaptcha($privatekey, new \ReCaptcha\RequestMethod\Curl());

        $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);

        if (!$resp->isSuccess()) {
            $event_array = array('NOTIFY_CONTACT_US_CAPTCHA_CHECK' => 'contact', 'NOTIFY_CREATE_ACCOUNT_CAPTCHA_CHECK' => 'create_account', 'NOTIFY_REVIEWS_WRITE_CAPTCHA_CHECK' => 'review_text');
            $messageStack->add($event_array[$eventID], $resp->getErrors());
            $error = true;
        }
        return $error;
    }
3 Mar 2018, 3:16 PM
#319
epilot avatar

epilot

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

Re: Support Thread for Google reCAPTCHA plugin

Thank you, lat9.

I will do what you suggested above and make another upload and then report in here.

3 Mar 2018, 6:57 PM
#320
epilot avatar

epilot

New Zenner

Join Date:
Feb 2018
Posts:
19
Plugin Contributions:
0

Re: Support Thread for Google reCAPTCHA plugin

Thank you very much for your help, lat9. It works in both "contact us' and 'create account'.

Could you please send me your information via PM on how to engage your services once Zen Cart v.1.6 is coming out.

Thank you again.