Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons

Reply
 
Thread Tools
reCAPTCHA v2 Human Verification Details »»
reCAPTCHA v2 Human Verification
Version: 1.0.0, by kh99 kh99 is offline
Developer Last Online: Sep 2020 Show Printable Version Email this Page

Category: Anti-Spam Options - Version: 4.x.x Rating:
Released: 12-10-2014 Last Update: 02-21-2015 Installs: 550
Uses Plugins Template Edits
Re-useable Code Additional Files Translations  
No support by the author.

(Note: This mod was renamed. The original name was "New reCAPTCHA Human Verification")

What is it?
----------------------------
This mod adds reCAPTCHA v2 as an option in the Human Verification Manager.

Note: The original reCAPTCHA used default keys if you didn't enter your own, so you could leave the key fields blank. This version requires you to have your own keys for your domain. To create them, go to this page (click on the "Get reCAPTCHA" button). It may take a short time after creating the keys before they will work, so if you get "ERROR: Invalid domain for site key", wait a while and try again.

vb3 version is here: https://vborg.vbsupport.ru/showthread.php?t=315964

Installation:
----------------------------
1) Upload the file in the "upload" folder to your server.

2) Import the product XML file from the Product Manager.

3) If you don't already have keys, go to this page and create keys for your domain. (If you already have keys you can get them from that page as well).

4) Go to Settings > Human Verification Manager, select "New reCAPTCHA" for the Verification Library, and click Save.

5) Enter your keys on the options page, and select the light or dark widget as desired (apparently white and black are the only options at this time). You could select "Audio" to default to audio instead of image for the challenge, but the widget seems to have a bug in it at the moment so I recommend leaving it set to "image". Click Save when you're done selecting options.

6) You can check the configuration and do a test by clicking on "Click here to test connection" which appears under the description in the Human Verification Manager.

7) Do a test registration (or other action that requires hv) to test that your keys are entered correctly and everything is working.

8) If you are upgrading from version 0.9, you can remove the file includes/class_humanverify_newrecaptcha.php (the one without the third underscore) from your server.

History:
----------------------------
1.0 (Feb 22, 2015)
  • Cached template (required renaming the uploaded file from
    class_humanverify_newrecaptcha.php to class_humanverify_new_recaptcha.php)
  • Removed default keys (which didn't work anyway)
  • Removed trademark symbols
  • Changed execution order of plugins from 5 to 4, to make sure this product
    works with another HV add-on that has a bug.
  • If "New reCAPTCHA" is selected when this mod is uninstalled, the hv library
    is switched to 'disabled'.
  • Added a test option to print out more information about verification failures

0.9 (Dec 11, 2014)
  • Initial Release

Download Now

File Type: zip kh99_new_recaptcha_v1_0.zip (46.9 KB, 3785 views)

Screenshots

File Type: jpg sg2.jpg (99.3 KB, 0 views)
File Type: png sg1.png (50.2 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #312  
Old 08-30-2018, 03:39 AM
rodriiverduguez rodriiverduguez is offline
 
Join Date: Dec 2017
Location: Buenos Aires
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by T.P. View Post
class_humanverify_new_recaptcha.php - Fixxed

PHP Code:
<?php

if (!isset($GLOBALS['vbulletin']->db))
{
    exit;
}

require_once(
DIR '/includes/class_vurl.php');

class 
vB_HumanVerify_New_Recaptcha extends vB_HumanVerify_Abstract
{
    public static 
$verify_url 'https://www.google.com/recaptcha/api/siteverify';
    
    
/**
    * Constructor
    *
    * @return    void
    */
    
function __construct(&$registry)
    {
        
parent::__construct($registry);
    }

    private static function 
get_error_phrase($result)
    {
        if (isset(
$result['error-codes']))
            
$errormsg current($result['error-codes']);
        else
            
$errormsg '';
        switch (
$errormsg)
        {
            case 
'missing-input-secret':
            case 
'invalid-input-secret':
                
$error 'humanverify_new_recaptcha_secret';
                break;
            case 
'missing-input-response':
                
$error 'humanverify_new_recaptcha_noanswer';
                break;
            case 
'invalid-input-response':
            default:
                
$error 'humanverify_new_recaptcha_wronganswer';
        }
        return 
$error;
    }


    function 
verify_token($input)
    {
        
$this->registry->input->clean_array_gpc('p', array(
            
'g-recaptcha-response' => TYPE_STR,
        ));

        if (
$this->delete_token($input['hash']) AND isset($this->registry->GPC['g-recaptcha-response']) AND 
                                                    
$this->registry->GPC['g-recaptcha-response'] !== '')
        {    
            
$secret urlencode($this->registry->options['hv_new_recaptcha_privatekey']);
            
$remoteip urlencode(IPADDRESS);
            
$response urlencode($this->registry->GPC['g-recaptcha-response']);

            
$vurl = new vB_vURL($this->registry);
            
$vurl->set_option(VURL_URLself::$verify_url."?secret=$secret&remoteip=$remoteip&response=$response");
            
$vurl->set_option(VURL_USERAGENT'vBulletin ' FILE_VERSION);
            
$vurl->set_option(VURL_RETURNTRANSFER1);
            
$vurl->set_option(VURL_CLOSECONNECTION1);

            if ((
$result $vurl->exec()) === false || ($result json_decode($resulttrue)) === NULL)
            {
                
$this->error 'humanverify_new_recaptcha_unreachable';
                return 
false;
            }
            else
            {
                if (
$result['success'] === true)
                {
                    return 
true;
                }
                
$this->error self::get_error_phrase($result);
                return 
false;
            }
        }
        else
        {
            
$this->error 'humanverify_new_recaptcha_wronganswer';
            return 
false;
        }
    }

    function 
output_token($var_prefix 'humanverify')
    {
        global 
$vbphrase$show;
        
$vbulletin =& $this->registry;

        
$humanverify $this->generate_token();

        
$humanverify['publickey'] = ($this->registry->options['hv_new_recaptcha_publickey'] ? $this->registry->options['hv_new_recaptcha_publickey'] : '');
        
$humanverify['theme'] = $this->registry->options['hv_new_recaptcha_theme'];
        
$humanverify['type'] = $this->registry->options['hv_new_recaptcha_type'];

        if (
preg_match('#^([a-z]{2})-?#i'vB_Template_Runtime::fetchStyleVar('languagecode'), $matches))
        {
            
$humanverify['hl'] = strtolower($matches[1]);
        }
        
        
$templater vB_Template::create('humanverify_new_recaptcha');
            
$templater->register('humanverify'$humanverify);
            
$templater->register('var_prefix'$var_prefix);
        
$output $templater->render();

        return 
$output;
    }

    function 
fetch_answer()
    {
        return 
'';
    }
    
    public static function 
test_check_config()
    {
        global 
$vbulletin;
        
$output = array();
        if (!
is_string($vbulletin->options['hv_new_recaptcha_publickey']) || $vbulletin->options['hv_new_recaptcha_publickey']=='')
            
$output[] = array(1'Site key is not set.');
        else
            
$output[] = array(0'Site key is set: '.$vbulletin->options['hv_new_recaptcha_publickey']);
        if (!
is_string($vbulletin->options['hv_new_recaptcha_privatekey']) || $vbulletin->options['hv_new_recaptcha_privatekey']=='')
            
$output[] = array(1'Secret key is not set.');
        else
            
$output[] = array(0'Secret key is set: '.$vbulletin->options['hv_new_recaptcha_privatekey']);
        if (!
function_exists('curl_init'))
            
$output[] = array(1'cURL must be enabled, and any curl_ functions must be removed from disable_functions in php.ini');
        else 
        {
            
$output[] = array(0'cURL is enabled');
                
$curlinfo curl_version();
           if (empty(
$curlinfo['ssl_version']))
                
$output[] = array(1'cURL does not have ssl enabled');
           else
           {
              
$o = array("cURL version info:");
              foreach (
$curlinfo AS $key=>$value)
              {
                 if (
$key == 'features')
                    
$value '0x'.dechex($value);
                 if (
$key == 'protocols')
                    
$value implode(', ',$value);
                 
$o[] = $key.': '.$value;
              }
              
$output[] = array(0$o);
           }
           if ((
$ch curl_init()) === false)
               
$output[] = array(1'curl_init failed');
           else
                
curl_close($ch);
             if (!
function_exists('curl_exec'))
              
$output[] = array(1'Function curl_exec is disabled. curl_exec must be removed from disable_functions in php.ini.');
           else
                
$output[] = array(0'curl_exec function is not disabled');
        }
    
        return 
$output;
    }

    public static function 
test_display_widget()
    {
        global 
$vbulletin;
        return 
'<script src="https://www.google.com/recaptcha/api.js" async defer></script>
            <div class="g-recaptcha" data-sitekey="'
.$vbulletin->options['hv_new_recaptcha_publickey'].'"></div>';
    }

    public static function 
test_verify()
    {
        global 
$vbulletin$vbphrase;
        
$output = array();
        
        
$vbulletin->input->clean_array_gpc('p', array(
            
'g-recaptcha-response' => TYPE_STR,
        ));
        
        if (!isset(
$vbulletin->GPC['g-recaptcha-response']) || $vbulletin->GPC['g-recaptcha-response'] == '')
            
$output[] = array(1'g-recaptcha-response is not set. Complete the human verification challenge before pressing Submit.');
        else
        {
            
$output[] = array(0'g-recaptcha-response: ' fetch_trimmed_title($vbulletin->GPC['g-recaptcha-response'], 50));
            
$secret urlencode($vbulletin->options['hv_new_recaptcha_privatekey']);
            
$remoteip urlencode(IPADDRESS);
            
$response urlencode($vbulletin->GPC['g-recaptcha-response']);
            
$url self::$verify_url."?secret=$secret&remoteip=$remoteip&response=$response";
            
$output[] = array(0"verify url: '".fetch_trimmed_title($url,160)."'");
            if ((
$ch curl_init()) !== false)
            {
                
curl_setopt($chCURLOPT_URL$url);
                
curl_setopt($chCURLOPT_TIMEOUT15);
                
curl_setopt($chCURLOPT_POST0);
                
curl_setopt($chCURLOPT_HEADER0);
                
curl_setopt($chCURLOPT_HTTPHEADER, array());
                
curl_setopt($chCURLOPT_RETURNTRANSFER1);
                
curl_setopt($chCURLOPT_FOLLOWLOCATION0);
                
curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
                
curl_setopt($chCURLOPT_SSL_VERIFYHOST0);

                
$result curl_exec($ch);
                if (
$result === false AND curl_errno($ch) == '60')
                {
                    
$output[] = array(0"Error 60, retrying with CAINFO");
                    
curl_setopt($chCURLOPT_CAINFODIR '/includes/paymentapi/ca-bundle.crt');
                    
$result curl_exec($ch);
                }
                
$info curl_getinfo($ch);
                if (
$result === false)
                   
$output[] = array(1"curl_exec returned false: ".curl_error($ch));
                else
                {
                    if (
$info['http_code'] != 200)
                        
$output[] = array(1"Http response code " $info['http_code']);
                    
$o = array("cURL transfer info:");
                    foreach (
$info AS $key=>$value)
                    {
                        
$o[] = $key.': '.$value;
                    }
                    
$output[] = array($info['http_code'] != 200$o);
                    if (
$info['http_code'] == 200)
                    {
                        
$output[] = array(0"Raw response: ".htmlspecialchars($result));
                        if ((
$result json_decode($resulttrue)) === NULL)
                           
$output[] = array(1"json_decode of response failed");
                        else
                        {
                            
$o = array("Decoded response:");
                            foreach (
$result AS $key=>$value)
                            {
                                if (
$key == 'success')
                                    
$value = ($value 'true' 'false');
                                if (
$key == 'error-codes')
                                    
$value implode(','$value);
                                
$o[] = $key.': '.$value;
                            }
                            
$output[] = array($result['success'] ? 1$o);
                            if (
$result['success'] !== true)
                            {
                                
$error self::get_error_phrase($result);
                                require_once(
DIR.'/includes/functions_misc.php');
                                
$output[] = array(1"Error Phrase: ".fetch_phrase($error'error'));
                            }
                        }
                    }
                    else
                        
$output[] = array(1"Http Response: ".htmlspecialchars($result));
                }
                
curl_close($ch);
            }
            else
                
$output[] = array(1"curl_init() failed.");
        } 
        return 
$output;
    }
}
?>
vBulletin updated the __constructor

Years ago I wanted to add it to my forum but I missed the registry error. Looking again I find your comment, I make the modification and ready. Problem solved, thank you very much. Plugin running in 4.2.5

translated by Google
Reply With Quote
Благодарность от:
djbaxter
  #313  
Old 09-12-2018, 07:06 AM
SuperTaz's Avatar
SuperTaz SuperTaz is offline
 
Join Date: Apr 2007
Location: Pennsylvania
Posts: 744
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When trying to add a new member they get this message using the fix a few posts above:

Code:
vBulletin Message
Unable to add cookies, header already sent.
File: /home2/public_html/forums/includes/class_humanverify_new_recaptcha.php
Line: 1
Global Gamers Forums
Any help on this?
Reply With Quote
  #314  
Old 09-12-2018, 06:34 PM
TheBang TheBang is offline
 
Join Date: Aug 2010
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So, I already did this for the vB3 version of this plugin several months ago. I had need to do a vB4 install too now, so I've done it for this one too:

I've repackaged this add-on into a 1.0.1 version, which you can download below. The main change is incorporating the required PHP fix (from above). So, this will work properly with vBulletin 4.2.5 and PHP 5.6/7.0/7.1. It should also work with earlier versions, though the minimum PHP version required is probably something like PHP 5.3.

I also updated all the UI elements to refer to the feature as "reCAPTCHA v2" instead of "New reCAPTCHA". I also updated the readme docs, correcting errors and typos.
Attached Files
File Type: zip kh99_recaptchav2_v1.0.1.zip (140.6 KB, 57 views)
Reply With Quote
6 благодарности(ей) от:
Alan_SP, CharlieDelta, kostastnt, Sean James, TheLastSuperman, z3r0
  #315  
Old 09-28-2018, 12:49 PM
doopz doopz is offline
 
Join Date: Feb 2003
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by TheBang View Post
So, I already did this for the vB3 version of this plugin several months ago. I had need to do a vB4 install too now, so I've done it for this one too:

I've repackaged this add-on into a 1.0.1 version, which you can download below. The main change is incorporating the required PHP fix (from above). So, this will work properly with vBulletin 4.2.5 and PHP 5.6/7.0/7.1. It should also work with earlier versions, though the minimum PHP version required is probably something like PHP 5.3.

I also updated all the UI elements to refer to the feature as "reCAPTCHA v2" instead of "New reCAPTCHA". I also updated the readme docs, correcting errors and typos.
Thank you! installed in 5 min and works flawlessly.
Reply With Quote
  #316  
Old 10-05-2018, 01:33 AM
Sean James's Avatar
Sean James Sean James is offline
 
Join Date: Apr 2004
Location: Sydney, Australia
Posts: 895
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When I try and upload the product XML file I am getting this error:

Access Denied - Sucuri Website Firewall
Block reason: An attempted XSS (Cross site scripting) was detected and blocked.
Reply With Quote
  #317  
Old 10-05-2018, 05:13 AM
NeoDio NeoDio is offline
 
Join Date: Jan 2011
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

vBulletin Message
Unable to add cookies, header already sent.
File: /home2/public_html/forums/includes/class_humanverify_new_recaptcha.php

I also get this message when new users register. Anyone know the fix for that?
Reply With Quote
  #318  
Old 10-05-2018, 05:20 AM
Sean James's Avatar
Sean James Sean James is offline
 
Join Date: Apr 2004
Location: Sydney, Australia
Posts: 895
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Sean James View Post
When I try and upload the product XML file I am getting this error:

Access Denied - Sucuri Website Firewall
Block reason: An attempted XSS (Cross site scripting) was detected and blocked.
All good problem fixed, was a server problem
Reply With Quote
  #319  
Old 10-16-2018, 08:31 PM
wawro wawro is offline
 
Join Date: Oct 2014
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It works fine on vb 4.2.3

No modification templates required.

Thanks a lot.

All The Best !
Reply With Quote
  #320  
Old 10-17-2018, 06:53 AM
rekha rekha is offline
 
Join Date: Jan 2012
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i m not able to set this on my forum pls help
Reply With Quote
  #321  
Old 10-18-2018, 08:52 PM
TheLastSuperman's Avatar
TheLastSuperman TheLastSuperman is offline
Senior Member
 
Join Date: Sep 2008
Location: North Carolina
Posts: 5,844
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by rekha View Post
i m not able to set this on my forum pls help
Make sure you've uploaded the file in the .zip which is class_humanverify_new_recaptcha.php

From there it's > AdminCP > Settings > Human Verification Manager > Set to ReCaptcha v2.

*Note the site key and secret site key i.e. copy them to notepad before changing to v2 and saving, if you do not copy them then when you save the recaptcha type as v2 it will redo the fields and they'll be empty and you'll lose the values (so if you copy now you won't need to login to google to get the keys again you can just copy/paste from notepad).

So that means it's three steps:
1) Upload the one required file.
2) Change the ReCaptcha to v2 in Human Verification Manager
3) Re-enter site key and secret site key in settings and save again.

Modification will be enabled after that.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:02 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.10235 seconds
  • Memory Usage 2,510KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (1)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (40)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (4)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete