Page 22 of 68 FirstFirst ... 12202122232432 ... LastLast
Results 211 to 220 of 673
  1. #211
    Join Date
    May 2008
    Location
    United States
    Posts
    454
    Plugin Contributions
    1

    Default Re: Support Thread for Google reCAPTCHA plugin

    Try this one:

    PHP Code:
    <?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
        } 
    }

  2. #212
    Join Date
    Aug 2010
    Location
    Hartland, MI
    Posts
    288
    Plugin Contributions
    3

    Default 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.

  3. #213
    Join Date
    May 2008
    Location
    United States
    Posts
    454
    Plugin Contributions
    1

    Default 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.

  4. #214
    Join Date
    Aug 2010
    Location
    Hartland, MI
    Posts
    288
    Plugin Contributions
    3

    Default Re: Support Thread for Google reCAPTCHA plugin

    Quote Originally Posted by marcopolo View Post
    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"
    PHP Code:
    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
    PHP Code:
    //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
    PHP Code:
    //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.

  5. #215
    Join Date
    May 2008
    Location
    United States
    Posts
    454
    Plugin Contributions
    1

    Default Re: Support Thread for Google reCAPTCHA plugin

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

  6. #216
    Join Date
    Aug 2010
    Location
    Hartland, MI
    Posts
    288
    Plugin Contributions
    3

    Default Re: Support Thread for Google reCAPTCHA plugin

    Quote Originally Posted by marcopolo View Post
    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

    class.faq_request.php.zip

  7. #217
    Join Date
    May 2008
    Location
    United States
    Posts
    454
    Plugin Contributions
    1

    Default Re: Support Thread for Google reCAPTCHA plugin

    Ok try the following, edit your file and add:

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

    PHP Code:
                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:

    PHP Code:
                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();
                    } 

  8. #218
    Join Date
    Aug 2010
    Location
    Hartland, MI
    Posts
    288
    Plugin Contributions
    3

    Default Re: Support Thread for Google reCAPTCHA plugin

    So this did NOT work:
    PHP Code:
                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!
    PHP Code:
      //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.

  9. #219
    Join Date
    May 2008
    Location
    United States
    Posts
    454
    Plugin Contributions
    1

    Default Re: Support Thread for Google reCAPTCHA plugin

    Ok great!

  10. #220
    Join Date
    Jul 2015
    Location
    Hoofddorp
    Posts
    76
    Plugin Contributions
    0

    Default 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)

 

 
Page 22 of 68 FirstFirst ... 12202122232432 ... LastLast

Similar Threads

  1. Support Thread for CKEditor Plugin
    By DivaVocals in forum Addon Admin Tools
    Replies: 213
    Last Post: 18 Nov 2024, 04:17 AM
  2. Back to Top Plugin [Support Thread]
    By picaflor-azul in forum All Other Contributions/Addons
    Replies: 31
    Last Post: 6 Feb 2016, 10:52 PM
  3. v151 Plug 'n' Pay plugin [Support Thread]
    By KetchRescue in forum Addon Payment Modules
    Replies: 5
    Last Post: 28 Nov 2015, 04:56 AM
  4. Justuno Plugin [Support Thread]
    By JustunoApp in forum All Other Contributions/Addons
    Replies: 8
    Last Post: 24 May 2015, 11:00 PM
  5. VendingBox Plugin Support Thread
    By vb_support in forum All Other Contributions/Addons
    Replies: 31
    Last Post: 10 Feb 2013, 07:24 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR