i get this error..any way tho fix it?
PHP Warning: sprintf(): Too few arguments in /home/XXXXX/XXXXX/catalog/controller/account/success.php on line 40

Also contact form dosent show captcha and aint working. (google enabled and basic captcha off) Theme: Default.
In General
Monday, April 29 2019, 12:52 PM
Share this post:
Responses (26)
  • Accepted Answer

    Monday, June 24 2019, 04:52 PM - #Permalink
    Hi John,

    Maybe your host provider may of mentioned a dedicated server if they thought large amounts of digital downloads may be likely.In particular video and audio could use a lot of bandwidth.

    Did you manage to get it all working?

    Regards,

    Hackasacka
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, May 02 2019, 03:25 PM - #Permalink
    Hackasacka wrote:

    Hi John,


    How did you reolve the Contact Form problem?


    Regards,


    Hackasacka
    I added Livechat app with contact form and maded notification popup for customers to use Chat contact form. Not the best solution but atleast something :) I have to say this platform is awesome, i managed to reduce resource usage and now it works like a charm. Now i focus to translate this fully to Finnish language.
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, May 02 2019, 02:23 PM - #Permalink
    Hi John,


    How did you reolve the Contact Form problem?


    Regards,


    Hackasacka
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, May 02 2019, 02:12 PM - #Permalink
    And for that "seeing" last person register info..well kinda problematic since customer is from norway and definetly not same computer in use...thats why i was little bit worried but maybe it was an bug or something. Atm not seeing last persons register info on register page / checkout pages.
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, May 02 2019, 02:06 PM - #Permalink
    Hi John,


    Would you mind setting this as a new topic as this may help when searching for solutions at a later date (seem to remember something like this before too) :-

    Quote

    But second question, is that why i am seeing last person register info at register page? This happens only Firefox browser, but not edge / chrome / vivaldi. I think this is very bad since if also customers can see last person register info or is my page chache messed up?

    Arastta stores some session data regarding "Registered" users like wish lists or products in the cart that were abandoned too etc.

    Are you using the same computer, but with different browsers for instance. The caching should be stored in the particular browser and the session data is on the server.

    Can you provide the steps you have taken to test for this potential issue so it can be followed and replicated please.


    Regards,


    Hackasacka
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, May 02 2019, 02:05 PM - #Permalink
    Hackasacka wrote:

    John,


    It would be enlightening to know what was changed to resolve your contact form issues using "Live Chat" ? Also, was it with the host provider?

    It would be possible to modify the forms so that they lookgood as HTML or pain text too. As security is an issue many companies choose not to view emails as HTML as it can then connect to the outside world and is more vulnerable to attack (the message looks better as HTML can be more of a desktop published experience). Content is king though.

    Glad you finally resolved it.


    Regards,


    Hackasacka


    Well i just added live chat and added notification to all customers that they only use "chat contact form". Since i cant get it to work normal. Capctha works tho but after sending message via contact form it dosent send it even it says "message has been sended to store" emails etc are all correct.
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, May 02 2019, 01:57 PM - #Permalink
    John,


    It would be enlightening to know what was changed to resolve your contact form issues using "Live Chat" ? Also, was it with the host provider?

    It would be possible to modify the forms so that they lookgood as HTML or pain text too. As security is an issue many companies choose not to view emails as HTML as it can then connect to the outside world and is more vulnerable to attack (the message looks better as HTML can be more of a desktop published experience). Content is king though.

    Glad you finally resolved it.


    Regards,


    Hackasacka
    The reply is currently minimized Show
  • Accepted Answer

    Thursday, May 02 2019, 01:22 AM - #Permalink
    Ok. I will test those out too, but i solved it by using live chat with contact form. But second question, is that why i am seeing last person register info at register page? This happens only Firefox browser, but not edge / chrome / vivaldi. I think this is very bad since if also customers can see last person register info or is my page chache messed up?
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 11:00 PM - #Permalink
    Hi John,


    With reference to the host provider blocking "PHPmail" (probably due to spamming problems) you may need to configure SMTP and an email account with the same domain name as the domain for the Arastta installation.

    Also, you may have more chance of receiving an email via PHPmail to an email account on the same server and domain.

    Is the email you have set in Arastta Admin ->Sytem -> Settings and email on the same domain as Arastta? If it isn't could you set up an email account and test it again?

    Microsoft email accounts often block or blacklist external emails from other hosts and also may require the message to have a good score in terms of it's quality too. Are they sent from the same domain, have they a subject, meaningful message etc.


    Regards,


    Hackasacka
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 07:21 PM - #Permalink
    Hi John,

    The contact form gets the email address to send to from your Arastta -> System ->Settings so this needs to be a valid email address.

    It is possible to override this email address by adding one directly to the contact form controller:-

    /catalog/controller/information/contact.php line 23:-

    $mail->setTo($this->config->get('config_email'));


    If you add this code after line 23 :-

     print_r($mail);
    die("code stops here");



    The code should now be :-

    <?php
    /**
    * @package Arastta eCommerce
    * @copyright 2015-2017 Arastta Association. All rights reserved.
    * @copyright See CREDITS.txt for credits and other copyright notices.
    * @license GNU GPL version 3; see LICENSE.txt
    * @link https://arastta.org
    */

    class ControllerInformationContact extends Controller {
    private $error = array();

    public function index() {
    $this->load->language('information/contact');

    $this->document->setTitle($this->language->get('heading_title'));

    if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
    $subject = $this->emailtemplate->getSubject('Contact', 'contact_1', $this->request->post);
    $message = $this->emailtemplate->getMessage('Contact', 'contact_1', $this->request->post);

    $mail = new Mail($this->config->get('config_mail'));
    $mail->setTo($this->config->get('config_email'));
    print_r($mail);
    die("code stops here");
    $mail->setFrom($this->request->post['email']);
    $mail->setSender($this->request->post['name']);
    $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
    $mail->setHtml(html_entity_decode(strip_tags($message), ENT_QUOTES, 'UTF-8'));
    $mail->send();



    This will halt execution of the contact form controller and your Arastta page will be text only debugging results similar to :-

    Mail Object ( [to:protected] => [email protected] [cc:protected] => [bcc:protected] => [from:protected] => [return_path:protected] => [read_receipt_to:protected] => [sender:protected] => [reply_to:protected] => [subject:protected] => [text:protected] => [html:protected] => [charset:protected] => [attachments:protected] => Array ( ) [attachments_inline:protected] => Array ( ) [priority:protected] => [config_mail_protocol] => phpmail [config_mail_sendmail_path] => /usr/sbin/sendmail -bs [config_mail_smtp_hostname] => [config_mail_smtp_username] => [config_mail_smtp_password] => [config_mail_smtp_port] => 25 [config_mail_smtp_encryption] => [protocol] => phpmail [parameter] => [sendmail_path] => /usr/sbin/sendmail -bs [smtp_hostname] => [smtp_username] => [smtp_password] => [smtp_port] => 25 [smtp_timeout] => 0 [smtp_encryption] => none ) code stops here



    Where it currently reads "[email protected]" should be the email you set in the Admin backend settings? Thus this may prove or otherwise that it has an valid email address or not?

    Obviously, you don't want to leave those lines in permanently it is just to debug your Arastta installation.

    As an additional test you could add a basic contact form to the root folder of your hosting or in fact any sub folder you set the path to in order to confirm the PHPmail function is working.

    Create a file called something like arasttacontact.php and past these contents into it :-

    <!doctype html>

    <html lang="en">

    <head>
    <m-eta charset="utf-8">

    <t-itle>The HTML5 Arastta Contact Form Test</title>
    <m-eta name="description" content="The HTML5 Herald">
    <m-eta name="author" content="Arastta">

    <!-- <l-ink rel="stylesheet" href="/css/styles.css?v=1.0"> -->

    </head>

    <body>
    <!-------------------------------------------------------------------------------------------------------------------->
    <?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $from = 'From: Arastta Test Form';
    $to = '[email protected]';
    $subject = 'Hello from Arastta Test Form';


    $body = "From: $name\n E-Mail: $email\n Message:\n $message";

    if ($_POST['submit']) {
    if (mail ($to, $subject, $body, $from)) {
    echo '<p>Your message has been sent!</p>';
    } else {
    echo '<p>Something went wrong, go back and try again!</p>';
    }
    }
    ?>
    <!---------------------------------------------------------------------------------------------------------------------------->

    <!-- contact section -->
    <form method="post" action="#">

    <label>Name</label>
    <input name="name" placeholder="Type Here">

    <label>Email</label>
    <input name="email" type="email" placeholder="Type Here">

    <label>Message</label>
    <textarea name="message" placeholder="Type Here"></textarea>

    <input id="submit" name="submit" type="submit" value="Submit">

    </form>
    </body>

    </html>


    You will need to change the email "$to = '[email protected]'; " to your test email to receive a message.

    Then access it directly url = johns-arastta-domain.com/arasttacontact.php

    It would be possible to then copy and paste most of the source file of the current contact page (so it looks the same as your design) only substituting your own form handling.

    However, if for instance you update the menu as this is now static HTML / PHP it would not get updated dynamically.



    Regards,



    Hackasacka
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 05:18 PM - #Permalink
    Hi John,

    The warning errors are because you mixed up the "Second" and "Default" templates. The instructions were to modify the "Default" template.

    Remember to keep a backup copy too.

    The "Default" template /catalog/view/theme/default/template/information/contact.tpl after line 132

                        <?php if ($captcha) { ?>
    <?php echo $captcha; ?>
    <?php } ?>
    <?php if ($site_key) { ?>
    <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
    <div class="g-recaptcha" data-sitekey="<?php echo $site_key; ?>"></div>
    <?php if ($error_captcha) { ?>
    <div class="text-danger"><?php echo $error_captcha; ?></div>
    <?php } ?>
    </div>
    </div>
    <?php } ?>
    </fieldset>


    The file that is processing the "Contact Form" is the controller (both default and second templates) :-

    catalog/controller/information/contact.php

    /**
    * @package Arastta eCommerce
    * @copyright 2015-2017 Arastta Association. All rights reserved.
    * @copyright See CREDITS.txt for credits and other copyright notices.
    * @license GNU GPL version 3; see LICENSE.txt
    * @link https://arastta.org
    */

    class ControllerInformationContact extends Controller {
    private $error = array();

    public function index() {
    $this->load->language('information/contact');

    $this->document->setTitle($this->language->get('heading_title'));

    if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
    $subject = $this->emailtemplate->getSubject('Contact', 'contact_1', $this->request->post);
    $message = $this->emailtemplate->getMessage('Contact', 'contact_1', $this->request->post);

    $mail = new Mail($this->config->get('config_mail'));
    $mail->setTo($this->config->get('config_email'));
    $mail->setFrom($this->request->post['email']);
    $mail->setSender($this->request->post['name']);
    $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
    $mail->setHtml(html_entity_decode(strip_tags($message), ENT_QUOTES, 'UTF-8'));
    $mail->send();

    $this->response->redirect($this->url->link('information/contact/success'));
    die("code ends here")
    }


    If everything is ok then it would finish by executing $mail->send(); and then proceed to link('information/contact/success') so your would see this in the URL at the top of your web browser and notice the page moves away from the Contact Form page.

    It should be possible to see what is happening using your web browser "inspection tools" (right-click -> left click "inspect element") then look for the "network" tab. It should be possible to see a PHP POST request at the top of the networking tab? It should be the top two lines.

    Notice there is also information about Headers, Cookies, Params and Response which should help you see if it is working. Params should contain fields in the form and

    Also, in the controller file you can stop the code running and output an error message using a PHP command - die("code ends here");

    $this->response->redirect($this->url->link('information/contact/success'));
    die("code ends here")


    Then when you click send look in the browser to see if you can see the message "code ends here" near the top usually. If you do see this you can confirm that the message was processed.

    If you have been receiving other messages from Arastta, then you could inspect this so you understand what to expect from the inspection tools. It also confirms that the PHPmail function is working too.

    Therefor the problem must lie within your System - Settings or the fix for the Default Contact Form. As mentioned you could remove the Basic Captcha. The Second Theme Contact Form has always worked, so not sure yet what is causing the problem. Good idea to use this theme for testing your mail function.

    With regards to the hosting of Arastta, it certainly does not require a dedicated server. Magenta Shopping cart is renowned for its heavy use of resources and Wordpress with Woocommerce is also bloated. Arastta and Opencart have a small footprint by comparison and hosting resource issues are not a common problem (unless hacked then you might see your mail working).

    If your host provider lets you setup sub-domains, then this should allow you to setup a clean install for testing purposes which would make it easier to help. Maybe consider using a remote access tool such as "Teaviewer" on a test desktop so someone could help directly.

    Just tested the "Second" contact form pasted into the "Default" template contact form and it works.


    Regards,


    Hackasacka
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 12:14 PM - #Permalink
    There is no problem with the resources, they're all green. And the contact form works on other cPanel servers running PHP 5.6 etc., so ....

    You could test disabling ModSecurity temporarily through cPanel, but all in all this issue is something you need to figure out of together with the host. The contact form should work, unless you have messed up the system or the server, it's as simple as that.
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 11:36 AM - #Permalink
    Well host is Shinjiru and they have best shared and dedi servers into market. I use also Breeze social platform with over active 600members and that dosent even use half of resources even the code is bigger that in arastta.
    And arastta uses resources now when 2people is actively search in website:
    https://i.ibb.co/GnhWWQX/something.png
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 11:23 AM - #Permalink
    Lol ... when they say it use huge amount resources you should move to another host, as they seems to be quite "funny". Your Arastta test/dev site surely doesn't use a huge amount resources, unless you're hacked. :)
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 10:44 AM - #Permalink
    Hello.
    I just contacted on my host/admin and they checked out and it seems that form dont "fetch" any email address where to send notifications or receiver. Nothing is either blocking it. Only what they said that this should be install on dedicated server since it uses huge amount resources.
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 10:40 AM - #Permalink
    Those are not errors, but notices, and they are not the reson your form doesn't work.
    So you need to talk to your server admin/host about this, something is most likely blocking.
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 10:05 AM - #Permalink
    I tested second theme also and tested that contact form and it´s same thing, it wount send any email.
    and this is from error log when using contact form:

    2019-04-30 17:02:55 - PHP Notice: Undefined variable: top in /home/path here/path here/catalog/view/theme/default/template/information/contact.tpl on line 2
    2019-04-30 17:02:55 - PHP Notice: Undefined variable: bottom_a in /home/path here/path here/catalog/view/theme/default/template/information/contact.tpl on line 151
    2019-04-30 17:02:55 - PHP Notice: Undefined variable: bottom_b in /home/path here/path here/catalog/view/theme/default/template/information/contact.tpl on line 158
    2019-04-30 17:02:55 - PHP Notice: Undefined variable: bottom_c in /home/path here/path here/catalog/view/theme/default/template/information/contact.tpl on line 165

    And i dont have any clue how to fix those. Thats why i am asking here.
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 10:00 AM - #Permalink
    OK, so you're on PHP 5.6 and there shouldn't normally be any problem with the contact form.

    Test it using Second theme and maybe also without Captcha, and if it still fails, I think you will need to ask your server admin/host to help you figure out why the form doesn't work on this server. Possibly something blocking it.
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 09:45 AM - #Permalink
    Sorry Rune, here is the information:

    Apache Version 2.4.39
    PHP Version 5.6.40
    MySQL Version 5.6.43
    Architecture x86_64
    Operating System linux
    Intel® C2350 (2c, 2t)
    4GB DDR3
    120 GB SSD /50Gb hdd raid(backup)
    Unmetered on 1gbps link
    --------------------------------
    Arastta version 1.6.2
    Default theme
    Default/Basic Captcha, working but not sending emails. *Worked out via adding Live chat with contact form.
    Paypal: Default *working*
    Rewards points: Enabled
    Affiliate: Enabled
    Language packet: Finnish
    Free checkout: Enabled
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 09:32 AM - #Permalink
    I'm sorry to see that you didn't include any system info as requested John, as that makes it quite impossible to tell what's going on.

    Anyhow you must pay attention to the fact that Arastta is not optimised for PHP 7.0+, you should use PHP 5.6 to ensure it's working.

    Also you should not just copy a file from one theme to another. Better test that those things are working when you're using Second, and if so, find and correct the difference making Default fail.

    You surely can use the info page section to add your own content, like a html contact form. But it's a bad idea ...
    https://arastta.org/docs/user-manual/catalog/informations
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, May 01 2019, 08:45 AM - #Permalink
    Okay lets see if this is okay form to ask/query for help.

    Theme: Default (no modifications in design)
    Basic captcha working now, since i copied second theme contact.tpl but issue is now that after typing contact form and type captcha it gives now information about that message has been taken, but it wount send it via email at all. And i am using PHPmail which works just fine with everything else but not in contact form. So what i am doing wrong? Tested STMP mailer also and not working either with contact form but everything else works. Is there possible to add "own" contact form and if yes, where i can put my own code like that it will show my contact form, not arastta contact form? And sorry my bad english.
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, April 30 2019, 01:44 PM - #Permalink
    Hi John,

    Ok your post first mentioned "(google enabled and basic captcha off)"? Perhaps that was at an earlier stage?

    The error warning you mentioned refers to customer groups, so maybe this would help track down the problem as can be seen in the code below:-

            if ($customer_group_info && !$customer_group_info['approval']) {
    $data['text_message'] = sprintf($this->language->get('text_message'), $this->url->link('information/contact'));
    } else {
    $data['text_message'] = sprintf($this->language->get('text_approval'), $this->config->get('config_name'), $this->url->link('information/contact'));
    }


    You may learn more by turning on debuging in the Admin - Systm - Setting - Server (tab).

    There was a known issue for the captcha with the "Default" template (in that it did not exist in the template). This is an old post so it may be helpful to search the forum first to see if there are already answers.

    It probably wasn't remedied in Arastta version 1.6.2?

    This should tell you enough to fix the issue.

    https://arastta.org/forum/contact-form-is-not-working-captcha-does-not-appear#reply-3251


    Regards,


    Hackasacka
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, April 30 2019, 11:37 AM - #Permalink
    You should definitely tell us something about your setup John.

    Your general system information would be a good start: https://arastta.org/docs/user-manual/tools/system-information

    And also add information about design used, and any extensions/modifications installed/applied.

    Anyhow the contact form works perfectly fine on a default clean setup, using the default Second theme and default captcha, on PHP 5.6 (which is the supported PHP version). Might be worth sticking to it if you can't debug/code, or find another cart, as this one is unsupported and probably dead.

    For the PHP error you definitely need to tell more about where and when you get it, but anyway, please stop mixing topics and do cross postings, it will create a mess for all. Please read and follow the forum rules: https://arastta.org/forum/forum-rules
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, April 30 2019, 04:24 AM - #Permalink
    Thanks for answering but i am not using googles v2 or v3. I am using the basic, it works when register/login, but not working when using contact form. There is definetly some problems.
    The reply is currently minimized Show
  • Accepted Answer

    Monday, April 29 2019, 09:16 PM - #Permalink
    Hi John,

    With regards to the captcha on the contact form page, you would need to set captcha to be "basic captcha" in "System-Settings-Security Captcha at the bottom of the page.

    In order to use Google Captcha you would require a Google site key and secret key https://developers.google.com/recaptcha/intro.

    Arastta is setup for Google re-captcha v2, but you may be able to implement Google re-captcha v3 that requires no human interface interaction.

    Here are two example tutorials that may help:-

    https://stevencotterill.com/articles/adding-google-recaptcha-v3-to-a-php-form/

    https://codeforgeek.com/google-recaptcha-v3-tutorial/

    Essentially, you would need your Google keys, modify the form in Arastta to validate the response from the Google re-captchav3 before sending the email.

    There will need to be a bit of Javascript for Google in the header of the page:-

        <scrip src="https://www.google.com/recaptcha/api.js?render=YOUR_RECAPTCHA_SITE_KEY"></scrip>
    <scrip>
    grecaptcha.ready(function () {
    grecaptcha.execute('YOUR_RECAPTCHA_SITE_KEY', { action: 'contact' }).then(function (token) {
    var recaptchaResponse = document.getElementById('recaptchaResponse');
    recaptchaResponse.value = token;
    });
    });
    </scrip>


    Then you need to modify:-
    public_html/catalog/controller/information/contact.php

    This code needs to exist to check the response from Google:-


    <?php // Check if form was submitted:
    if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['recaptcha_response'])) {

    // Build POST request:
    $recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
    $recaptcha_secret = 'YOUR_RECAPTCHA_SECRET_KEY';
    $recaptcha_response = $_POST['recaptcha_response'];

    // Make and decode POST request:
    $recaptcha = file_get_contents($recaptcha_url . '?secret=' . $recaptcha_secret . '&response=' . $recaptcha_response);
    $recaptcha = json_decode($recaptcha);

    // Take action based on the score returned:
    if ($recaptcha->score >= 0.5) {
    // Verified - send email
    } else {
    // Not verified - show form error
    }

    } ?>


    If you refer to the code above where it reads:-

    "    if ($recaptcha->score >= 0.5) {
    // Verified - send email"


    This is where you you would need to have the existing code in the Arastta controller:-


    if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
    $subject = $this->emailtemplate->getSubject('Contact', 'contact_1', $this->request->post);
    $message = $this->emailtemplate->getMessage('Contact', 'contact_1', $this->request->post);

    $mail = new Mail($this->config->get('config_mail'));
    $mail->setTo($this->config->get('config_email'));
    $mail->setFrom($this->request->post['email']);
    $mail->setSender($this->request->post['name']);
    $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
    $mail->setHtml(html_entity_decode(strip_tags($message), ENT_QUOTES, 'UTF-8'));
    $mail->send();

    $this->response->redirect($this->url->link('information/contact/success'));
    }



    The html part of the Arastta contact form is in the contact form template (or tpl) which is what the public see and is the "view" of the MVC design:-

    public_html/catalog/controller/information/contact.tpl" or "public_html/catalog/view/theme/default/template/information/contact.tpl"

    This form needs to have a hidden input for Google to be able to provide a response when the form is submitted with a click of the submit button.

    The Arastta form submit needs to be changed from:-


    <div class="buttons">
    <div class="pull-right">
    <input class="btn btn-primary" type="submit" value="<?php echo $button_submit; ?>" />
    </div>
    </div>


    To


    <div class="buttons">
    <div class="pull-right">
    <input class="btn btn-primary" type="submit" value="<?php echo $button_submit; ?>" />
    <input type="hidden" name="recaptcha_response" id="recaptchaResponse">
    </div>
    </div>


    Hope this helps.

    Regards,

    Hackasacka
    The reply is currently minimized Show
  • Accepted Answer

    Monday, April 29 2019, 07:56 PM - #Permalink
    Hi John,

    With regards to the captcha on the contact form page, you would need to set captcha to be "basic captcha" in "System-Settings-Security Captcha at the bottom of the page.

    In order to use Google Captcha you would require a Google site key and secret key https://developers.google.com/recaptcha/intro.

    Arastta is setup for Google re-captcha v2, but you may be able to implement Google re-captcha v3 that requires no human interface interaction.

    Here are two example tutorials that may help:-

    https://stevencotterill.com/articles/adding-google-recaptcha-v3-to-a-php-form/

    https://codeforgeek.com/google-recaptcha-v3-tutorial/

    Essentially, you would need your Google keys, modify the form in Arastta to validate the response from the Google re-captchav3 before sending the email.

    There will need to be a bit of Javascript for Google in the header of the page:-



    grecaptcha.ready(function () {
    grecaptcha.execute('YOUR_RECAPTCHA_SITE_KEY', { action: 'contact' }).then(function (token) {
    var recaptchaResponse = document.getElementById('recaptchaResponse');
    recaptchaResponse.value = token;
    });
    });


    Then you need to modify "public_html/catalog/view/theme/second/template/information/contact.tpl" or "public_html/catalog/view/theme/default/template/information/contact.tpl"

    This code needs to exist to check the response from Google:-


    <?php // Check if form was submitted:
    if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['recaptcha_response'])) {

    // Build POST request:
    $recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
    $recaptcha_secret = 'YOUR_RECAPTCHA_SECRET_KEY';
    $recaptcha_response = $_POST['recaptcha_response'];

    // Make and decode POST request:
    $recaptcha = file_get_contents($recaptcha_url . '?secret=' . $recaptcha_secret . '&response=' . $recaptcha_response);
    $recaptcha = json_decode($recaptcha);

    // Take action based on the score returned:
    if ($recaptcha->score >= 0.5) {
    // Verified - send email
    } else {
    // Not verified - show form error
    }

    } ?>



    If you refer to the code above where it reads:-

    "    if ($recaptcha->score >= 0.5) {
    // Verified - send email"


    This is where you would need to have the Arastta form:-

                <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" class="form-horizontal">
    <fieldset>
    <h3><?php echo $text_contact; ?></h3>
    <div class="form-group required">
    <label class="col-sm-2 control-label" for="input-name"><?php echo $entry_name; ?></label>
    <div class="col-sm-10">
    <input type="text" name="name" value="<?php echo $name; ?>" id="input-name" class="form-control" />
    <?php if ($error_name) { ?>
    <div class="text-danger"><?php echo $error_name; ?></div>
    <?php } ?>
    </div>
    </div>
    <div class="form-group required">
    <label class="col-sm-2 control-label" for="input-email"><?php echo $entry_email; ?></label>
    <div class="col-sm-10">
    <input type="text" name="email" value="<?php echo $email; ?>" id="input-email" class="form-control" />
    <?php if ($error_email) { ?>
    <div class="text-danger"><?php echo $error_email; ?></div>
    <?php } ?>
    </div>
    </div>
    <div class="form-group required">
    <label class="col-sm-2 control-label" for="input-enquiry"><?php echo $entry_enquiry; ?></label>
    <div class="col-sm-10">
    <textarea name="enquiry" rows="10" id="input-enquiry" class="form-control"><?php echo $enquiry; ?></textarea>
    <?php if ($error_enquiry) { ?>
    <div class="text-danger"><?php echo $error_enquiry; ?></div>
    <?php } ?>
    </div>
    </div>
    <?php if ($captcha) { ?>
    <?php echo $captcha; ?>
    <?php } ?>
    </fieldset>
    <div class="buttons">
    <div class="pull-right">
    <input class="btn btn-primary" type="submit" value="<?php echo $button_submit; ?>" />
    </div>
    </div>
    </form>


    Hope this helps.

    Regards,


    Hackasacka
    The reply is currently minimized Show
Your Reply