Jump to content
motion2082

Add reCAPTCHA to Prestashop Version 1.6.0.14 for FREE

Recommended Posts

Hello Hervé..
Thank you very much for your module.
 

I just new installed this module, on prestashop 1.7.2.0.

its work for Captcha for account creation, but error on Captcha for contact form, reCaptcha not displayed.

How to fix it? i am sorry for my English.

Share this post


Link to post
Share on other sites

 

Hello Hervé..
Thank you very much for your module.
 

I just new installed this module, on prestashop 1.7.2.0.

its work for Captcha for account creation, but error on Captcha for contact form, reCaptcha not displayed.

How to fix it? i am sorry for my English.

 

Hello,

In order to work with prestashop 1.7 you have to install the module contactform before.

Have you do this, do you use a custom theme ?

 

Regards,

Share this post


Link to post
Share on other sites

Attention the module eicaptcha-master.zip contains the module sendtoafriend do not install it!

If you had read the documentation of the module before posting , you should have seen that the module overrides functionnalities of the module sendtoafriend in order to add a captcha on it.

And that this override have to be done manually.

 

So please avoid to tell nosense things if you do not understand how it works...

Share this post


Link to post
Share on other sites

First of all, thank you for this module, quite surprised it is not already included in "stock" PS. Currently using v 1.7.2 and your version downloaded from here: https://www.h-hennes.fr/blog/wp-content/uploads/2017/07/eicaptcha-17-beta.zip

 

It is now being displayed correctly on both forms, however it doesn't seem to work as I was able to send message using the contact us form without validating captcha. There is even message being displayed after submit - Your message has been successfully sent to our team. And the message is recorded in BO.

 

Perhaps I missed something in settings...?

Edited by mr_absinthe

Share this post


Link to post
Share on other sites

Hi

Very nice contribution. There's just one comment from our side: you should move the javascript code (//Insertion de la div qui va contenir le captcha dans la page) out from the main PHP and have it in a separate file, as once installed, it is cached, and no changes to the script are taken into consideration, not even after re-install.

Cheers

Share this post


Link to post
Share on other sites
On 06/04/2016 at 3:43 PM, sekwoja said:

I believe that there is some problem with controller, because eicaptcha.php in reference to contact form adds only couple of lines written in Javascript (jQuery). And above-mentioned code does nothing more than inputting recaptcha google api by means of JS/jQuery:


$(document).ready(function(){
            
               //Add div where the captcha will be displayed
               $(".submit").before("<div id=\"captcha-box\"></div>");
               
               //Manage form submit
                $("#submitMessage").click(function(){
                    //If no response we display an error
                    if ( ! grecaptcha.getResponse() ) {
                        $.ajax({
                                method : "POST",
                                url : "'._MODULE_DIR_.$this->name.'/eicaptcha-ajax.php",
                                data : "action=display_captcha_error",
                                success : function(msg){
                                    $(".'.$error_class.'").remove();    
                                    $("form.'.$form_class.'").before(msg);
                                }
                            });
                       
                        return false;
                    }
                });
            });

This solution may be helpful for some other users having issues with reCaptcha on Prestashop. So, after hours of tries I gave up and took code delivered by google (this one below) and put it inside my header.tpl.


<script src='https://www.google.com/recaptcha/api.js'></script>

Than I copied and pasted this:


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

into contact-form.tpl in my theme. After couple of tries it turned out that it still doesnt work so I opened contactController.php and added:


else   if   ( ! ( $gcaptcha   =   ( int ) ( Tools:: getValue ( 'g-recaptcha-response' ) ) ) )

$this -> errors [ ]   =   Tools:: displayError ( 'Captcha nie zweryfikowana' ) ;

before last else in line 50 in public function postProccess.

 

Now it works. I am still wondering what is wrong with EiCaptcha module, because when it comes to create account page it works like a charm. The only one problem is on contact form page.

 

it is not very clear from the OP how to use this module to provide the complete security needed, because if you do have a real spam problem then they still bypass the captcha on the contact form even after installing this module and following the first post.

so, I wanted to make it clear, that not only do you need to follow the first post of this thread, but you will also need to write in the code from the quoted post above and into to the contactcontroller.php

the response from the JS however is in another language, but someone else also found this solution too which can be found here: https://www.prestashop.com/forums/topic/609900-spammer-bypasses-contact-form-captcha-no-effect/?do=findComment&comment=255718

 

now, i tried the solution that is provided in the link above, but it didn't work at first, but after comparing both codes I was able to establish that it has a "{" "}" in the code 

example

} else if (!($gcaptcha = (int)(Tools::getValue('g-recaptcha-response')))){

    $this->errors[] = Tools::displayError('Captcha not verified');

            }

that code above didn't work, it just threw the contact page but the below code is what worked for me on 1.6.0.14

 else if (!($gcaptcha = (int)(Tools::getValue('g-recaptcha-response'))))

    $this->errors[] = Tools::displayError('Captcha not verified');

although the OP of this thread tells you to put the following code into the contact page 

<script src=https://www.google.com/recaptcha/api.js'></script>

it might need to go into the header.tpl, I can't be certain if this makes a difference or not, but most certainly updating the controller was needed in order to stop the spamming.

 

thank you to all the contributors for your solutions. I would just like to add that it would be very handy if the OP can edit the first post to include the solutions so it can save PS users a lot of time. and possible damage to reputation.

 

Share this post


Link to post
Share on other sites

If anyone is having problems with module not appearing in BO - this might be the case of UPPERCASE or lowercase module folder name - if the module is not appearing, rename "EICAPTCHA" to "eicaptcha"!

This happens to some hosting providers using certain OS for servers - if Your hosting provider uses Linux/Unix, "EICAPTCHA" folder name will cause the error and module will not be visible in BO.

Share this post


Link to post
Share on other sites

If You want to choose Captcha interface language:

1. Open file "eicaptcha.php" inside the module folder (using "Notepad" or "Notepad++");

2. Find this part of the code at the end of the file (actual line is around 306):

		$js .= '<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>';

Edit the very end by adding "&hl=FR", where FR is French - just pick Your language code respectively. Should look like this:

		$js .= '<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit&hl=fr" async defer></script>';

You can pick whichever language You want. This change will work for contact form only - You need to change the code lines for Account creation, Send to a Friend by finding same code lines with "recaptcha/api.js" and adding the small code segment.

Share this post


Link to post
Share on other sites

Hi, thank you so much, works for me 1.6.1.4 but shows the following error:

Notice: Undefined index: captcha in /home/web/public_html/tools/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 253

Notice: Trying to get property of non-object in /home/web/public_html/tools/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 253

Anyone can help me please? Thanks!

Share this post


Link to post
Share on other sites
On 9/3/2017 at 2:47 AM, mr_absinthe said:

First of all, thank you for this module, quite surprised it is not already included in "stock" PS. Currently using v 1.7.2 and your version downloaded from here: https://www.h-hennes.fr/blog/wp-content/uploads/2017/07/eicaptcha-17-beta.zip

 

It is now being displayed correctly on both forms, however it doesn't seem to work as I was able to send message using the contact us form without validating captcha. There is even message being displayed after submit - Your message has been successfully sent to our team. And the message is recorded in BO.

 

Perhaps I missed something in settings...?

this module working fine with prestashop 1.7.2.4

for spamming will notify here.

thanks for this module.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×