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

Support Thread for Google reCAPTCHA plugin

Views: 176,327

Results 201 to 220 of 694
24 Sep 2015, 2:54 PM
#201
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Support Thread for Google reCAPTCHA plugin

David Allen:

Hi Mike
Just had a quick look at it (nice site btw). I think what you need to do is in the class.faq_request.php file:

Add at the beginning of the function update (just after the global $messagestack):

$error=false;
$zco_notifier->notify('NOTIFY_FAQ_CAPTCHA_CHECK');

> 
> then change the line 2 below from 
> ```
if(isset($_POST['email_address']) && !empty($_POST['email_address']) && isset($_POST['fullname']) && !empty($_POST['fullname']) && isset($_POST['message']) && !empty($_POST['message']) && isset($_POST['subject']) && !empty($_POST['subject'])) {

to

if(isset($_POST['email_address']) && !empty($_POST['email_address']) && isset($_POST['fullname']) && !empty($_POST['fullname']) && isset($_POST['message']) && !empty($_POST['message']) && isset($_POST['subject']) && !empty($_POST['subject']) && $error==false) {

> 
> in the class.google_recaptcha.php file add (line 23 ish)
> ```
$pages_to_check[] =  'NOTIFY_FAQ_CAPTCHA_CHECK';

Hopefully that should sort it - if not I'll have another look

Regards
David

David,
Thanks. I finally got a chance to get back to this (one of the many challenges of being a small business and doing our own site development!). After the changes you suggested are put in place the product info page dies with the following error:
PHP Fatal error: Call to a member function notify() on a non-object in /home3/wwwsica/public_html/store-1st_1-5-4/includes/classes/observers/class.faq_request.php on line 38

That is the $zco_notifier->notify('NOTIFY_FAQ_CAPTCHA_CHECK'); line I added in. I am gong to commect the line out for now intil I can find the solution.
Thanks again

Mike

30 Sep 2015, 8:40 PM
#202
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: Support Thread for Google reCAPTCHA plugin

Ok so I have made a few more attempts at putting this in to the Ajax FAQ module, with no luck. Everything shows, but the check doesn't happen, and the question is sent regardless of the reCaptcha.
Like I said b4 the $zco_notifier->notify('NOTIFY_FAQ_CAPTCHA_CHECK'); inside of the class.faq_request.php kills the page with an error, so I tried moving the notify to the tpl_modules_faq_questions.php file. Top or bottom of the file this didn't work.

Also as this is an ajax pop-up how would I add it to the $event_array line in the class.google_recaptcha.php file?

Thanks for any ideas

18 Oct 2015, 7:48 PM
#203
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: Support Thread for Google reCAPTCHA plugin

mikestaps:

Ok so I have made a few more attempts at putting this in to the Ajax FAQ module, with no luck. Everything shows, but the check doesn't happen, and the question is sent regardless of the reCaptcha.
Like I said b4 the $zco_notifier->notify('NOTIFY_FAQ_CAPTCHA_CHECK'); inside of the class.faq_request.php kills the page with an error, so I tried moving the notify to the tpl_modules_faq_questions.php file. Top or bottom of the file this didn't work.

Also as this is an ajax pop-up how would I add it to the $event_array line in the class.google_recaptcha.php file?

Thanks for any ideas

mikestaps did you ever get this working on the FAQ page? I'm having a similar problem.

18 Oct 2015, 10:00 PM
#204
david_allen avatar

david_allen

Zen Follower

Join Date:
Feb 2008
Location:
Amersham, Buckinghamshire, United Kingdom
Posts:
141
Plugin Contributions:
1

Re: Support Thread for Google reCAPTCHA plugin

Hi. To fix the $zco_notifier->notify('NOTIFY_FAQ_CAPTCHA_CHECK') error, I think all you need to do is add

global $zco_notofier;
``` just before it
Regards
19 Oct 2015, 7:10 PM
#205
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: Support Thread for Google reCAPTCHA plugin

David Allen:

Hi. To fix the $zco_notifier->notify('NOTIFY_FAQ_CAPTCHA_CHECK') error, I think all you need to do is add

global $zco_notofier;

> Regards

Hmm I have the code there however it's still ignoring the reCAPTCHA no matter if checked or unchecked. My issue sounded like the same issue as mikestaps  was having so I was hopping he resolved it and would share how he was able to make it work.
19 Oct 2015, 8:04 PM
#206
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: Support Thread for Google reCAPTCHA plugin

I have not be able to get it fully working, as I had moved this one to the back burner temporarily as I have other upgrades, etc. to make before going live.
Adding the ```
global $zco_notifier;

I now having it working, except for the error message when you do not check the "I'm not a robot" box,
It will currently show the "Please fill in the required information and submit it again. Thank you." error, then when you check the box it sends properly.
Almost there...

This is what I have in the class.faq_request.php file:
<?php // // +----------------------------------------------------------------------+ // |zen-cart Open Source E-commerce | // +----------------------------------------------------------------------+ // | Copyright (c) 2007-2008 Numinix Technology http://www.numinix.com | // | | // | Portions Copyright (c) 2003-2006 Zen Cart Development Team | // | http://www.zen-cart.com/index.php | // | | // | Portions Copyright (c) 2003 osCommerce | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the GPL license, | // | that is bundled with this package in the file LICENSE, and is | // | available through the world-wide-web at the following url: | // | http://www.zen-cart.com/license/2_0.txt. | // | If you did not receive a copy of the zen-cart license and are unable | // | to obtain it through the world-wide-web, please send a note to | // | [email protected] so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // $Id: class.store_credit.php 12 2010-09-03 20:44:47Z numinix $ // /** * Observer class used to handle reward points in an order * */ class faqRequest extends base { function faqRequest() { global $zco_notifier; $zco_notifier->attach($this, array('NOTIFY_HEADER_END_PRODUCT_INFO')); } function update(&$class, $eventID, $paramsArray) { global $messageStack; //bof google recaptcha global $zco_notifier, $error; $error = false; $zco_notifier->notify('NOTIFY_FAQ_CAPTCHA_CHECK'); //eof google rcaptcha $fullname = zen_db_prepare_input($_POST['fullname']); $email_address = zen_db_prepare_input($_POST['email_address']); $subject = zen_db_prepare_input($_POST['subject']); $message = zen_db_prepare_input($_POST['message']); //$captcha = (int)zen_db_prepare_input($_POST['captcha']); $extra_info = email_collect_extra_info($name, $email_address, $customer_name, $customer_email); if(isset($_GET['action']) && $_GET['action'] == 'faq_request') { if(isset($_POST['email_address']) && !empty($_POST['email_address']) && isset($_POST['fullname']) && !empty($_POST['fullname']) && isset($_POST['message']) && !empty($_POST['message']) && $error==false) { // captcha //if($captcha !== (int)$_SESSION['simpleCaptcha']) { // echo json_encode(array('status' => 'error', 'message' => 'You have entered a wrong code. Please edit it and try again!')); // exit(); //} //bof google recaptcha //$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); if (!$resp->is_valid) { // set the error code so that we can display it //$messageStack->add($event_array[$eventID], $resp->getErrors()); $error = true; //echo json_encode(array('status' => 'error', 'message' => 'Please confirm you are not a robot.')); //exit(); } //eof google recaptcha $sql_data_array = array( 'products_id' => (int)$_GET['products_id'], 'products_model' => zen_get_products_model ((int)$_GET['products_id']), 'products_name' => zen_get_products_name((int)$_GET['products_id']), 'fullname' => $fullname, 'email_address' => $email_address, 'subject' => $subject, 'message' => $message, 'date_created' => 'now()' ); zen_db_perform(DB_PREFIX . 'faq_questions', $sql_data_array); $subject = sprintf('You have a new question about the %s', zen_get_products_name((int)$_GET['products_id'], $_SESSION['languages_id'])); $textmsg = $message . "\n\n" . $extra_info['TEXT']; // Prepare HTML-portion of message $html_msg['EMAIL_MESSAGE_HTML'] = $message; $html_msg['CONTACT_US_OFFICE_FROM'] = ''; $html_msg['EXTRA_INFO'] = $extra_info['HTML']; zen_mail(STORE_NAME, EMAIL_FROM, $subject, $textmsg, $fullname, $email_address, $html_msg, 'contact_us'); if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { echo json_encode(array('status' => 'success', 'message' => 'We have received your question. We will respond to you as quickly as possible. Thank you for asking.')); } else { $messageStack->add_session('product_info', 'Your question has been sent, we will reply as soon as possible. Thank you!', 'success'); zen_redirect(zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$_GET['products_id'])); } } else { if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { echo json_encode(array('status' => 'error', 'message' => 'Please fill in the required information and submit it again. Thank you.')); } else { $messageStack->add_session('product_info', 'Please fill in all information and try again!', 'warning'); zen_redirect(zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$_GET['products_id'])); } } exit(); } } } ``` and these are the changes I made to the class.google_recaptcha.php file: ``` <?php /** * * @package plugins * @copyright Copyright 2003-2012 Zen Cart Development Team * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * * Designed for v1.5.4 * Observer class for Google reCaptcha */ class google_recaptcha extends base { /** * @var array */ private $pages_to_checkcheck = array(); function __construct() { //comment out any pages you do NOT want to check $pages_to_check[] = 'NOTIFY_CONTACT_US_CAPTCHA_CHECK'; $pages_to_check[] = 'NOTIFY_CREATE_ACCOUNT_CAPTCHA_CHECK'; //$pages_to_check[] = 'NOTIFY_REVIEWS_WRITE_CAPTCHA_CHECK'; $pages_to_check[] = 'NOTIFY_FAQ_CAPTCHA_CHECK'; $pages_to_check[] = 'NOTIFY_FAQ_PAGE_CAPTCHA_CHECK'; $this->attach($this,$pages_to_check); } 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; } } ```
19 Oct 2015, 9:37 PM
#207
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: Support Thread for Google reCAPTCHA plugin

Thanks for the reply I fixed my issue I had the: ```php
&& $error==false

19 Oct 2015, 9:47 PM
#208
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: Support Thread for Google reCAPTCHA plugin

mikestaps's if you trying to get it to display a messagestack error for example "Please check the the reCAPTCHA form." then you probably have to add a ```php
$messageStack->add('WHATEVER-PAGE-NAME', GOOGLE_RECAPTCHA_CHECK_ERROR);

class.google_recaptcha.php file at the bottom for that page. My file is different since I'm not using what is available for download. I added the 2.0 reCAPTCHA myself before it was available for download by David so my implantation is slightly different. Below is how I did it so you can get an idea:

```php
// Zencart stuff
class google_recaptcha extends base {
	function __construct() {
			$this->attach($this, array('NOTIFY_CONTACT_US_CAPTCHA_CHECK', 'NOTIFY_CREATE_ACCOUNT_CAPTCHA_CHECK', 'NOTIFY_TRACKING_CAPTCHA_CHECK'));
	}

	function update(&$class, $eventID, $paramsArray = array()) {
		global $messageStack, $error, $secret;
		$event_array = array('NOTIFY_CONTACT_US_CAPTCHA_CHECK' => 'contact', 'NOTIFY_CREATE_ACCOUNT_CAPTCHA_CHECK' => 'create_account', 'NOTIFY_TRACKING_CAPTCHA_CHECK' => 'tracking');
		// reCAPTCHA response?
		if(isset($_POST['g-recaptcha-response'])){
          $captcha=$_POST['g-recaptcha-response'];
        }
        if(!$captcha){
		  $messageStack->add('contact', GOOGLE_RECAPTCHA_CHECK_ERROR);
		  $messageStack->add('create_account', GOOGLE_RECAPTCHA_CHECK_ERROR);
		  $messageStack->add('tracking', GOOGLE_RECAPTCHA_CHECK_ERROR);
          $error = true;
        }
	return $error;
	}
}
21 Oct 2015, 8:44 PM
#209
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: Support Thread for Google reCAPTCHA plugin

mikestaps's try the below for your class.google_recaptcha.php file:

<?php
/**
*
* @package plugins
* @copyright Copyright 2003-2012 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
*
* Designed for v1.5.4
* Observer class for Google reCaptcha
*/

class google_recaptcha extends base {
	/**
	 * @var array
	 */
	private $pages_to_checkcheck = array();

	function __construct() {

		//comment out any pages you do NOT want to check
		$pages_to_check[] =  'NOTIFY_CONTACT_US_CAPTCHA_CHECK';
		$pages_to_check[] =  'NOTIFY_CREATE_ACCOUNT_CAPTCHA_CHECK';
		//$pages_to_check[] =  'NOTIFY_REVIEWS_WRITE_CAPTCHA_CHECK';
		$pages_to_check[] =  'NOTIFY_FAQ_CAPTCHA_CHECK';
		$pages_to_check[] =  'NOTIFY_FAQ_PAGE_CAPTCHA_CHECK';
		$this->attach($this,$pages_to_check);
	}

	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', 'NOTIFY_FAQ_CAPTCHA_CHECK' => 'faq', 'NOTIFY_FAQ_PAGE_CAPTCHA_CHECK' => 'faq_page');
			$messageStack->add($event_array[$eventID], $resp->getErrors());
			$error = true;
		}
		return $error;
	}
}
21 Oct 2015, 9:13 PM
#210
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: Support Thread for Google reCAPTCHA plugin

marcopolo:

mikestaps's if you trying to get it to display a messagestack error for example "Please check the the reCAPTCHA form." then you probably have to add a ```php
$messageStack->add('WHATEVER-PAGE-NAME', GOOGLE_RECAPTCHA_CHECK_ERROR);


> **marcopolo:**
>
> mikestaps's try the below for your class.google_recaptcha.php file:

I tried both with no luck. When I added the mesage stack error it locked things up and the FAQ wouldn't submit, and the class file had no effect.
Thanks
21 Oct 2015, 9:22 PM
#211
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: Support Thread for Google reCAPTCHA plugin

Try this one:

<?php 
/** 
* 
* @package plugins 
* @copyright Copyright 2003-2012 Zen Cart Development Team 
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 
* 
* Designed for v1.5.4 
* Observer class for Google reCaptcha 
*/ 

class google_recaptcha extends base { 
    /** 
     * @var array 
     */ 
    private $pages_to_checkcheck = array(); 

    function __construct() { 

        //comment out any pages you do NOT want to check 
        $pages_to_check[] =  'NOTIFY_CONTACT_US_CAPTCHA_CHECK'; 
        $pages_to_check[] =  'NOTIFY_CREATE_ACCOUNT_CAPTCHA_CHECK'; 
        //$pages_to_check[] =  'NOTIFY_REVIEWS_WRITE_CAPTCHA_CHECK'; 
        $pages_to_check[] =  'NOTIFY_FAQ_CAPTCHA_CHECK'; 
        $pages_to_check[] =  'NOTIFY_FAQ_PAGE_CAPTCHA_CHECK'; 
        $this->attach($this,$pages_to_check); 
    } 

    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', 'NOTIFY_FAQ_CAPTCHA_CHECK' => 'faq', 'NOTIFY_FAQ_PAGE_CAPTCHA_CHECK' => 'faq_page'); 
            $messageStack->add($event_array[$eventID], $resp->getErrors());
            $messageStack->add('faq', GOOGLE_RECAPTCHA_CHECK_ERROR);
            $messageStack->add('faq_page', GOOGLE_RECAPTCHA_CHECK_ERROR);
 
            $error = true; 
        } 
        return $error; 
    } 
}
21 Oct 2015, 9:52 PM
#212
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: Support Thread for Google reCAPTCHA plugin

Nope again.... This one is definately different, I think it is because it is a ajax loaded form on the product info page (and setting the mesage stack page to product info does not work, tried it.).
Take a look at it HERE, click on the Ask a Question link.

21 Oct 2015, 10:31 PM
#213
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: Support Thread for Google reCAPTCHA plugin

Ok so the popup displays the following if not checked:

"Please fill in the required information and submit it again. Thank you."

So I would suggest finding where that message is coded, then whatever file that is you should be able to add an additional messageStack to it for the reCAPTCHA.

22 Oct 2015, 8:50 PM
#214
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: Support Thread for Google reCAPTCHA plugin

marcopolo:

Ok so the popup displays the following if not checked:

"Please fill in the required information and submit it again. Thank you."

So I would suggest finding where that message is coded, then whatever file that is you should be able to add an additional messageStack to it for the reCAPTCHA.

That error message is handled in the class.faq_request.php file with the following line"

if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
          echo json_encode(array('status' => 'error', 'message' => 'Please fill in the required information and submit it again. Thank you.'));
        } else {
          $messageStack->add_session('product_info', 'Please fill in all information and try again!', 'warning');
          zen_redirect(zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$_GET['products_id']));
        }

I attempted to add this using that format

//bof google recaptcha
			if (!$resp->is_valid) {
			  $error = true;
			  echo json_encode(array('status' => 'error', 'message' => 'Please confirm you are not a robot.'));
			  exit();
			} //eof google recaptcha

When I did that this error message shows up regardless of if you check the recaptcha.

I also tried

//bof google recaptcha
			$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
			if (!$resp->is_valid) {
			$error = true;
			echo json_encode(array('status' => 'error', 'message' => 'Please confirm you are not a robot.'));
			exit();
			} //eof google recaptcha

This does nothing when you click the send button regardless of if you check the recaptcha. (it actually gives a 500 internal server error)

I'm thinking that the issue is actually in the way it is checking the recaptcha and that it thinks the recaptcha is empty no matter what.

I think the reason that it is working the way it is now is because the ajax form sees the recaptcha as a field, if that field is empty it returns 'Please fill in the required information and submit it again. Thank you.', if ALL of the fields have "something" then it returns 'We have received your question. We will respond to you as quickly as possible. Thank you for asking.' and sends the message.

22 Oct 2015, 9:53 PM
#215
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: Support Thread for Google reCAPTCHA plugin

can you post the whole contents of class.faq_request.php

23 Oct 2015, 1:22 PM
#216
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: Support Thread for Google reCAPTCHA plugin

marcopolo:

can you post the whole contents of class.faq_request.php

Here is my current file and the one included with the ajax FAQ mod

Attachment #15743

23 Oct 2015, 9:23 PM
#217
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: Support Thread for Google reCAPTCHA plugin

Ok try the following, edit your file and add:

				if ($error == true) {
				echo json_encode(array('status' => 'error', 'message' => 'Please confirm you are not a robot'));
				exit();
				}

below line:

			if(isset($_POST['email_address']) && !empty($_POST['email_address']) && isset($_POST['fullname']) && !empty($_POST['fullname']) && isset($_POST['message']) && !empty($_POST['message']) && $error==false) {

should look like:

			if(isset($_POST['email_address']) && !empty($_POST['email_address']) && isset($_POST['fullname']) && !empty($_POST['fullname']) && isset($_POST['message']) && !empty($_POST['message']) && $error==false) {

				if ($error == true) {
				echo json_encode(array('status' => 'error', 'message' => 'Please confirm you are not a robot'));
				exit();
				}
26 Oct 2015, 2:28 PM
#218
mikestaps avatar

mikestaps

Zen Follower

Join Date:
Aug 2010
Location:
Grand Blanc, MI
Posts:
305
Plugin Contributions:
1

Re: Support Thread for Google reCAPTCHA plugin

So this did NOT work:

			if(isset($_POST['email_address']) && !empty($_POST['email_address']) && isset($_POST['fullname']) && !empty($_POST['fullname']) && isset($_POST['message']) && !empty($_POST['message']) && $error==false) {

				if ($error == true) {
				echo json_encode(array('status' => 'error', 'message' => 'Please confirm you are not a robot'));
				exit();
				}

It is checking if $error == true after it has already confirmed $error == false.

But this did work!

			
  //bof google recaptcha check
     if ($error == true) {
	echo json_encode(array('status' => 'error', 'message' => 'Please confirm you are not a robot.'));
	exit();
	}
  //eof google recaptcha check
				
  if(isset($_POST['email_address']) && !empty($_POST['email_address']) && isset($_POST['fullname']) && !empty($_POST['fullname']) && isset($_POST['message']) && !empty($_POST['message']) && $error==false) {

Thanks for getting me headed in the right direction.

26 Oct 2015, 6:45 PM
#219
marcopolo avatar

marcopolo

Totally Zenned

Join Date:
May 2008
Location:
United States
Posts:
516
Plugin Contributions:
2

Re: Support Thread for Google reCAPTCHA plugin

Ok great!

30 Oct 2015, 8:18 AM
#220
cj_dekrijger avatar

cj_dekrijger

New Zenner

Join Date:
Jul 2015
Location:
Hoofddorp
Posts:
76
Plugin Contributions:
0

Re: Support Thread for Google reCAPTCHA plugin

Hello,

I don't know if I am at the right place here but i haven's seen a "start thread" option. Here's
my problem.
reCAPTCHA is n't working all the time i haven't seen it on the new account page and not
always on the contact us page. i checked the files they are all there in the right place, checked
google key's they are also in the right file?
So what can be wrong in my situation ? (check itparts.biz/zentest)