Quantcast
Channel: MyBB Community Forums - Tutorials
Viewing all articles
Browse latest Browse all 687

[Deprecated since MyBB 1.8.4] noCaptcha with MyBB

$
0
0
WARNING! And over again. This tutorial require core edits inside class_captcha.php file.

Well. noticed info above?
So let's start.

1. Make template edit.
Find member_register_regimage_recaptcha (let me help you. Is located at Member Templates).
Find:
Code:
<script type="text/javascript" src="{$server}/challenge?k={$public_key}"></script>

And replace it with:
Code:
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="{$public_key}"></div>

2. Make core file edit.
I think best solution would be telling which line of code were replaced. so:
At line 283 (as of latest commited file) find:
PHP Code:
283. $challenge $mybb->input['recaptcha_challenge_field'];
284. $response $mybb->input['recaptcha_response_field'];
[[
285 --> 327]]
328. $answer explode("\n"$response[1]);
329. if(trim($answer[0]) != 'true')
330. {
331. // We got it wrong! Oh no...
332. $this->set_error($lang->invalid_captcha_verify);
333. }
334. }
335. }
336. 

And replace everything with:
PHP Code:
$response $mybb->input['g-recaptcha-response'];

if(!
$response || strlen($response) == 0) {
    
$this->set_error($lang->invalid_captcha);
} else {
    
$google_url "https://www.google.com/recaptcha/api/siteverify";
    
$url $google_url."?secret=".$mybb->settings['captchaprivatekey']."&response=".$response."&remoteip=".$session->ipaddress;
 
               
    $nocaptchareply 
= @file_get_contents($url);

    
$res json_decode($nocaptchareplytrue);
    if(!
$res['success']) {
        
$this->set_error($lang->invalid_captcha_verify);
    }


3. Language edits (OBSOLETE):
go to your member.lang.php and find:
PHP Code:
$l['verification_note'] = "Please enter the text contained within the image into the text box below it. This process is used to prevent automated processes.";
[....]
$l['error_regimageinvalid'] = "The image verification code that you entered was incorrect. Please enter the code exactly how it appears in the image.";
$l['error_regimagerequired'] = "Please fill out the image verification code to continue the login process. Please enter the code exactly how it appears in the image."

And edit them as you'd like to be appared. For example:

PHP Code:
$l['verification_note'] = "Please checkbox a square. This process is used to prevent automated processes.";
[....]
$l['error_regimageinvalid'] = "Please click the checkbox.";
$l['error_regimagerequired'] = "Something went wrong. Please retry again."

And that's all Smile
More info about noCaptcha can be found [here] and [here]

Edit: This tutorial will be deprecated (as of MyBB Developers included noCaptcha in next release).

Viewing all articles
Browse latest Browse all 687

Trending Articles