"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Upload/inc/class_captcha.php" between
mybb_1822.zip and mybb_1823.zip

About: MyBB is a multilingual, standards-compliant and free forum (discussion board) software.

class_captcha.php  (mybb_1822):class_captcha.php  (mybb_1823)
skipping to change at line 42 skipping to change at line 42
* THE SOFTWARE. * THE SOFTWARE.
* *
*/ */
class captcha class captcha
{ {
/** /**
* Type of CAPTCHA. * Type of CAPTCHA.
* *
* 1 = Default CAPTCHA * 1 = Default CAPTCHA
* 2 = reCAPTCHA
* 4 = NoCATPCHA reCAPTCHA * 4 = NoCATPCHA reCAPTCHA
* 5 = reCAPTCHA invisible
* 6 = hCaptcha
* 7 = hCaptcha invisible
* 8 = reCAPTCHA v3
* *
* @var int * @var int
*/ */
public $type = 0; public $type = 0;
/** /**
* The template to display the CAPTCHA in * The template to display the CAPTCHA in
* *
* @var string * @var string
*/ */
skipping to change at line 115 skipping to change at line 118
$this->captcha_template = $template; $this->captcha_template = $template;
if($this->type == 4) if($this->type == 4)
{ {
$this->captcha_template .= "_nocaptcha"; $this->captcha_template .= "_nocaptcha";
} }
elseif($this->type == 5) elseif($this->type == 5)
{ {
$this->captcha_template .= "_recaptcha_invisible" ; $this->captcha_template .= "_recaptcha_invisible" ;
} }
elseif($this->type == 6)
{
$this->captcha_template .= "_hcaptcha";
}
elseif($this->type == 7)
{
$this->captcha_template .= "_hcaptcha_invisible";
}
elseif($this->type == 8)
{
$this->captcha_template .= "_recaptcha_invisible"
;
}
} }
// Work on which CAPTCHA we've got installed // Work on which CAPTCHA we've got installed
if(in_array($this->type, array(4, 5)) && $mybb->settings['captcha publickey'] && $mybb->settings['captchaprivatekey']) if(in_array($this->type, array(4, 5, 8)) && $mybb->settings['reca ptchapublickey'] && $mybb->settings['recaptchaprivatekey'])
{ {
// We want to use noCAPTCHA or reCAPTCHA invisible, set t he server options // We want to use noCAPTCHA or reCAPTCHA invisible, set t he server options
$this->server = "//www.google.com/recaptcha/api.js"; $this->server = "//www.google.com/recaptcha/api.js";
$this->verify_server = "https://www.google.com/recaptcha/ api/siteverify"; $this->verify_server = "https://www.google.com/recaptcha/ api/siteverify";
if($build == true) if($build == true)
{ {
$this->build_recaptcha(); $this->build_recaptcha();
} }
} }
elseif(in_array($this->type, array(6, 7)) && $mybb->settings['hca
ptchapublickey'] && $mybb->settings['hcaptchaprivatekey'])
{
// We want to use hCaptcha or hCaptcha invisible, set the
server options
$this->server = "//www.hcaptcha.com/1/api.js";
$this->verify_server = "https://hcaptcha.com/siteverify";
if($build == true)
{
$this->build_hcaptcha();
}
}
elseif($this->type == 1) elseif($this->type == 1)
{ {
if(!function_exists("imagecreatefrompng")) if(!function_exists("imagecreatefrompng"))
{ {
// We want to use the default CAPTCHA, but it's n ot installed // We want to use the default CAPTCHA, but it's n ot installed
return; return;
} }
elseif($build == true) elseif($build == true)
{ {
$this->build_captcha(); $this->build_captcha();
skipping to change at line 173 skipping to change at line 199
eval("\$this->html = \"".$templates->get($this->captcha_template) ."\";"); eval("\$this->html = \"".$templates->get($this->captcha_template) ."\";");
//eval("\$this->html = \"".$templates->get("member_register_regim age")."\";"); //eval("\$this->html = \"".$templates->get("member_register_regim age")."\";");
} }
function build_recaptcha() function build_recaptcha()
{ {
global $lang, $mybb, $templates; global $lang, $mybb, $templates;
// This will build a reCAPTCHA // This will build a reCAPTCHA
$server = $this->server; $server = $this->server;
$public_key = $mybb->settings['captchapublickey']; $public_key = $mybb->settings['recaptchapublickey'];
eval("\$this->html = \"".$templates->get($this->captcha_template, 1, 0)."\";"); eval("\$this->html = \"".$templates->get($this->captcha_template, 1, 0)."\";");
//eval("\$this->html = \"".$templates->get("member_register_regim age_recaptcha")."\";"); //eval("\$this->html = \"".$templates->get("member_register_regim age_recaptcha")."\";");
} }
function build_hcaptcha()
{
global $lang, $mybb, $templates;
// This will build a hCaptcha
$server = $this->server;
$public_key = $mybb->settings['hcaptchapublickey'];
$captcha_theme = $mybb->settings['hcaptchatheme'];
$captcha_size = $mybb->settings['hcaptchasize'];
eval("\$this->html = \"".$templates->get($this->captcha_template,
1, 0)."\";");
}
/** /**
* @return string * @return string
*/ */
function build_hidden_captcha() function build_hidden_captcha()
{ {
global $db, $mybb, $templates; global $db, $mybb, $templates;
$field = array(); $field = array();
if($this->type == 1) if($this->type == 1)
skipping to change at line 255 skipping to change at line 294
$response = $mybb->input['g-recaptcha-response']; $response = $mybb->input['g-recaptcha-response'];
if(!$response || strlen($response) == 0) if(!$response || strlen($response) == 0)
{ {
$this->set_error($lang->invalid_nocaptcha); $this->set_error($lang->invalid_nocaptcha);
} }
else else
{ {
// We have a noCAPTCHA or reCAPTCHA invisible to handle // We have a noCAPTCHA or reCAPTCHA invisible to handle
// Contact Google and see if our reCAPTCHA was su ccessful // Contact Google and see if our reCAPTCHA was su ccessful
$response = fetch_remote_file($this->verify_serve r, array( $response = fetch_remote_file($this->verify_serve r, array(
'secret' => $mybb->settings['captchapriva tekey'], 'secret' => $mybb->settings['recaptchapri vatekey'],
'remoteip' => $session->ipaddress, 'remoteip' => $session->ipaddress,
'response' => $response 'response' => $response
)); ));
if($response == false) if($response == false)
{ {
$this->set_error($lang->invalid_nocaptcha _transmit); $this->set_error($lang->invalid_nocaptcha _transmit);
} }
else else
{ {
$answer = json_decode($response, true); $answer = json_decode($response, true);
if($answer['success'] != 'true') if($answer['success'] != 'true')
{ {
// We got it wrong! Oh no... // We got it wrong! Oh no...
$this->set_error($lang->invalid_n ocaptcha); $this->set_error($lang->invalid_n ocaptcha);
} }
} }
} }
} }
elseif($this->type == 8)
{
$response = $mybb->input['g-recaptcha-response'];
if(!$response || strlen($response) == 0)
{
$this->set_error($lang->invalid_nocaptcha);
}
else
{
// We have a reCAPTCHA invisible to handle
// Contact Google and see if our reCAPTCHA was su
ccessful
$response = fetch_remote_file($this->verify_serve
r, array(
'secret' => $mybb->settings['recaptchapri
vatekey'],
'score' => $mybb->settings['recaptchascor
e'],
'remoteip' => $session->ipaddress,
'response' => $response
));
if($response === false)
{
$this->set_error($lang->invalid_nocaptcha
_transmit);
}
else
{
$answer = json_decode($response, true);
if($answer['success'] != 'true' || $answe
r['score'] < $mybb->settings['recaptchascore'])
{
// We got it wrong! Oh no...
$this->set_error($lang->invalid_n
ocaptcha);
}
}
}
}
elseif(in_array($this->type, array(6, 7)))
{
$response = $mybb->input['h-captcha-response'];
if(!$response || strlen($response) == 0)
{
$this->set_error($lang->invalid_hcaptcha);
}
else
{
// We have an hCaptcha or hCaptcha invisible to h
andle
// Contact hCaptcha and see if our hCaptcha was s
uccessful
$response = fetch_remote_file($this->verify_serve
r, array(
'secret' => $mybb->settings['hcaptchapriv
atekey'],
'remoteip' => $session->ipaddress,
'response' => $response
));
if($response == false)
{
$this->set_error($lang->invalid_hcaptcha_
transmit);
}
else
{
$answer = json_decode($response, true);
if($answer['success'] != 'true')
{
// We got it wrong! Oh no...
$this->set_error($lang->invalid_h
captcha);
}
}
}
}
$plugins->run_hooks('captcha_validate_end', $this); $plugins->run_hooks('captcha_validate_end', $this);
if(count($this->errors) > 0) if(count($this->errors) > 0)
{ {
return false; return false;
} }
else else
{ {
return true; return true;
} }
 End of changes. 10 change blocks. 
4 lines changed or deleted 125 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)