Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Happy New Year Gift!

This discussion is related to the No Captcha ReCaptcha addon.

I know that some people have been asking for this.

So I thought it would be a good new year's eve project.

For those that don't know Google reCAPTCHA has a new improved API

https://www.google.com/recaptcha/intro/index.html

This plugin will add a registration option for it.

grep is your friend.

R_JBleistivthgtonightAdrianphreakperegrineShadowdarejackmaessenMakke375Deprecatedz
«1

Comments

  • Unfortunately this breaks user registration. I continually get the error "passwords do not match," while this is enabled. Disabling it fixes the problem. Could this be related to the body tag?

  • x00x00 MVP
    edited January 2015

    is it a public site? Could be malformed markup.

    grep is your friend.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited January 2015

    If you want to use the dark theme for the box you can add parameters to the div that holds the box , in the case below I went with the dark theme adding data-theme="dark" if you want audio instead of image add data-type="audio"

    function recaptcha_get_html($CaptchaPublicKey, $Error = NULL, $UseSsl = FALSE){
            return'<div class="g-recaptcha" data-theme="dark" data-sitekey="'.$CaptchaPublicKey.'"></div>';
        }
    }
    

    https://developers.google.com/recaptcha/docs/display

    nc.png 146.1K
  • @vrijvlinder said:
    If you want to use the dark theme for the box you can add parameters to the div that holds the box....

    I take it the plugin works for you?

    I'll change to this:

    function recaptcha_get_html($CaptchaPublicKey, $Error = NULL, $UseSsl = FALSE){
        $Attributes =  C('Plugins.NoCaptchaReCaptcha.Attributes', array());
        $Attributes = array_merge($Attributes,array('class'=>'g-recaptcha', 'data-sitekey'=>$CaptchaPublicKey));
        $Plugin = Gdn::PluginManager()->GetPluginInstance('NoCaptchaReCaptcha');
        if($Plugin){
            $Plugin->EventArguments['Attributes'] = &$Attributes;
            $Plugin->FireEvent('BeforeDivReturn');
        }
        return'<div '.Attribute($Attributes).'></div>';
    }
    

    Then you can set $Configuration['Plugins']['NoCaptchaReCaptcha']['Attributes']= array('data-theme'=>'dark');

    grep is your friend.

    hgtonight
  • Very nice.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    @Nitwit said:
    Unfortunately this breaks user registration. I continually get the error "passwords do not match," while this is enabled.

    I got that too. I think the form is too sensitive on focus.
    If you ignore the error and go to the captcha and enter the text, it says verified you are not a robot and the page refreshes. The password seems to have been accepted because it does not say that it does not match anymore. However you get the Humanity is suspect error even if you entered the text correctly.

    So something is not working . Maybe the server side validation...

    The same key you had for the old captcha seems to be the same for this one since it is site wide. I could not get new keys or rather no new keys are available.

  • HazuluHazulu New
    edited January 2015

    Yeah, Even if I put in the same password it still tells me they don't match. I can still hit sign up and everything goes through normally and the account does get registered. (This was on localhost)

    vrijvlinder
  • thanks for the feedback.

    grep is your friend.

  • When people get "password don't match" is this the dynamic typing check, or is it after submission?

    grep is your friend.

  • Ok regarding the password check I think I can reproduce the error, will make a fix shortly.

    grep is your friend.

  • Ok here we go

    http://vanillaforums.org/addon/nocaptcharecaptcha-plugin

    @vrijvlinder I have put some error handling but I would still like an url, becuase it could be a javascript issue.

    grep is your friend.

  • Hi. The new version 0.1.3b seems to be broken. I just deactivated the older one... deleted it from the server.... uploaded the new version... and when I now try to activate the plugin I get the following error message:

    'The addon could not be enabled because it generated a fatal error'

  • Good catch. That is an enabling only relating issue. Will update the plugin.

    grep is your friend.

  • Hi. Right now I tested version 0.1.4b. Unfortunately same error as with former version 0.1.3b. :(
    Rolling back to version 0.1.1b which is working (apart from the known bug)...

    Makke375
  • @Stoertebecker said:
    Hi. Right now I tested version 0.1.4b. Unfortunately same error as with former version 0.1.3b. :(
    Rolling back to version 0.1.1b which is working (apart from the known bug)...

    it should not produce an error, try merging files without disabling. Or if you disable, set the current registration method to something else.

    grep is your friend.

  • x00x00 MVP
    edited January 2015

    If you want to find out what the error is put

    $Configuration['Debug'] = TRUE;

    in config.php

    then enable the plugin.

    grep is your friend.

  • Ok... here is the error message:

    Fatal error: Can't use function return value in write context in /home/xxxxxx/public_html/plugins/NoCaptchaReCaptcha/default.php on line 156

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    @x00 said:
    When people get "password don't match" is this the dynamic typing check, or is it after submission?

    Sorry I was out...

    No it is when you focus the input box on one , and then focus on the other without entering any text you get passwords don't match, but since they do match upon checking the captcha and submitting then refreshes and the message about passwords not matching is gone.

    I did not get any js errors of any kind. Just my humanity suspect upon filing out the captcha everytime.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited January 2015

    Ok I think I fixed it for myself this is what I did to the default.

    if(C('EnabledPlugins.NoCaptchaReCaptcha') && C('Garden.Registration.Method')=='NoCaptcha'){
        function ValidateCaptcha($Value){
            $Response = ArrayValue('g-recaptcha-response', $_POST, '');
    
            if(!$Response)
                return FALSE;
    
            $Url = 'https://www.google.com/recaptcha/api/siteverify';
            $Data = array(
                'secret' => C('Garden.Registration.CaptchaPrivateKey'),
                'response' => ArrayValue('g-recaptcha-response', $_POST, '')
            );
    
            $Handler = curl_init();
            curl_setopt($Handler, CURLOPT_URL, $Url);
            curl_setopt($Handler, CURLOPT_PORT, '443');
            curl_setopt($Handler, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($Handler, CURLOPT_HEADER, FALSE);
            curl_setopt($Handler, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded")); 
            curl_setopt($Handler, CURLOPT_USERAGENT, ArrayValue('HTTP_USER_AGENT', $_SERVER, 'NoCaptchaReCaptcha Vanilla'));
            curl_setopt($Handler, CURLOPT_RETURNTRANSFER, TRUE);
            curl_setopt($Handler, CURLOPT_POST, TRUE);
            curl_setopt($Handler, CURLOPT_POSTFIELDS, http_build_query($Data));
    
            $Response = curl_exec($Handler);
            if($Response){
                $Result = json_decode($Response);
                if($Result && GetValue('success', $Result))
                    return TRUE;
            }
    
            return FALSE;
        }
    
    
        function recaptcha_get_html($CaptchaPublicKey, $Error = NULL, $UseSsl = FALSE){
            $Attributes =  C('Plugins.NoCaptchaReCaptcha.Attributes', array());
            $Attributes = array_merge($Attributes,array('class'=>'g-recaptcha', 'data-sitekey'=>$CaptchaPublicKey));
            $Plugin = Gdn::PluginManager()->GetPluginInstance('NoCaptchaReCaptcha');
            if($Plugin){
                $Plugin->EventArguments['Attributes'] = &$Attributes;
                $Plugin->FireEvent('BeforeDivReturn');
            }
            return'<div '.Attribute($Attributes).'></div>';
        }
    }
    

    You can go test it at http://www.cosmicjustice.org

  • @Stoertebecker said:
    Ok... here is the error message:

    Fatal error: Can't use function return value in write context in /home/xxxxxx/public_html/plugins/NoCaptchaReCaptcha/default.php on line 156

    Ok hopefully this should be it.

    http://vanillaforums.org/addon/nocaptcharecaptcha-plugin

    grep is your friend.

  • x00x00 MVP
    edited January 2015

    @vrijvlinder said:
    I did not get any js errors of any kind. Just my humanity suspect upon filing out the captcha everytime.

    can you try the latest version please?

    grep is your friend.

    Hazulu
  • HazuluHazulu New
    edited January 2015

    Just tested the newest build and it worked great, thanks for the share :).

    EDIT: Tested on a live site and I get whoops! view not found. Could it have something to do with the url rewrite I toggled?

  • Nevermind, forgot it isn't a new page :p.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited January 2015

    Tested on my site and I get whoops! view not found. And it breaks my css

  • The gift the keeps on giving...

    grep is your friend.

    peregrine
  • x00x00 MVP
    edited January 2015

    @vrijvlinder said:
    Tested on my site and I get whoops! view not found. And it breaks my css

    It appears to be working on your site

    grep is your friend.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    @x00 said:
    It appears to be working on your site

    no I tested the new plugin version on my site vrijvlinder.com I wanted to test it in two sites to compare wtf...

    I had to delete the plugin coz it cause some fatal error with the sql user table when I disabled it and went back to settings page.

«1
Sign In or Register to comment.