Vergleich inc/class_captcha.php - 1.8.17 - 1.8.24

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 39Zeile 39
	 * Type of CAPTCHA.
*
* 1 = Default CAPTCHA

	 * Type of 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
*/

Zeile 109Zeile 112
				$this->captcha_template .= "_nocaptcha";
}
elseif($this->type == 5)

				$this->captcha_template .= "_nocaptcha";
}
elseif($this->type == 5)

 
			{
$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

			{
$this->captcha_template .= "_recaptcha_invisible";
}
}

// Work on which CAPTCHA we've got installed

		if(in_array($this->type, array(4, 5)) && $mybb->settings['captchapublickey'] && $mybb->settings['captchaprivatekey'])

		if(in_array($this->type, array(4, 5, 8)) && $mybb->settings['recaptchapublickey'] && $mybb->settings['recaptchaprivatekey'])

		{
// We want to use noCAPTCHA or reCAPTCHA invisible, set the server options
$this->server = "//www.google.com/recaptcha/api.js";
$this->verify_server = "https://www.google.com/recaptcha/api/siteverify";

if($build == true)

		{
// We want to use noCAPTCHA or reCAPTCHA invisible, set the server options
$this->server = "//www.google.com/recaptcha/api.js";
$this->verify_server = "https://www.google.com/recaptcha/api/siteverify";

if($build == true)

			{
$this->build_recaptcha();












			{
$this->build_recaptcha();
}
}
elseif(in_array($this->type, array(6, 7)) && $mybb->settings['hcaptchapublickey'] && $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)

Zeile 132Zeile 158
			{
// We want to use the default CAPTCHA, but it's not installed
return;

			{
// We want to use the default CAPTCHA, but it's not installed
return;

			}

			}

			elseif($build == true)
{
$this->build_captcha();

			elseif($build == true)
{
$this->build_captcha();

Zeile 152Zeile 178
		// This will build a MyBB CAPTCHA
$randomstr = random_str(5);
$imagehash = md5(random_str(12));

		// This will build a MyBB CAPTCHA
$randomstr = random_str(5);
$imagehash = md5(random_str(12));





		$insert_array = array(
"imagehash" => $imagehash,
"imagestring" => $randomstr,

		$insert_array = array(
"imagehash" => $imagehash,
"imagestring" => $randomstr,

Zeile 162Zeile 188
		$db->insert_query("captcha", $insert_array);
eval("\$this->html = \"".$templates->get($this->captcha_template)."\";");
//eval("\$this->html = \"".$templates->get("member_register_regimage")."\";");

		$db->insert_query("captcha", $insert_array);
eval("\$this->html = \"".$templates->get($this->captcha_template)."\";");
//eval("\$this->html = \"".$templates->get("member_register_regimage")."\";");

	}


	}


	function build_recaptcha()
{
global $lang, $mybb, $templates;


	function build_recaptcha()
{
global $lang, $mybb, $templates;


		// This will build a reCAPTCHA













		// This will build a reCAPTCHA
$server = $this->server;
$public_key = $mybb->settings['recaptchapublickey'];

eval("\$this->html = \"".$templates->get($this->captcha_template, 1, 0)."\";");
//eval("\$this->html = \"".$templates->get("member_register_regimage_recaptcha")."\";");
}

function build_hcaptcha()
{
global $lang, $mybb, $templates;

// This will build a hCaptcha

		$server = $this->server;

		$server = $this->server;

		$public_key = $mybb->settings['captchapublickey'];




		$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)."\";");

		eval("\$this->html = \"".$templates->get($this->captcha_template, 1, 0)."\";");

		//eval("\$this->html = \"".$templates->get("member_register_regimage_recaptcha")."\";");

 
	}

/**

	}

/**

Zeile 213Zeile 252
		global $db, $lang, $mybb, $session, $plugins;

$plugins->run_hooks('captcha_validate_start', $this);

		global $db, $lang, $mybb, $session, $plugins;

$plugins->run_hooks('captcha_validate_start', $this);





		if($this->type == 1)
{
// We have a normal CAPTCHA to handle

		if($this->type == 1)
{
// We have a normal CAPTCHA to handle

Zeile 233Zeile 272

$query = $db->simple_select("captcha", "*", "imagehash = '{$imagehash}' AND {$field} = '{$imagestring}'");
$imgcheck = $db->fetch_array($query);


$query = $db->simple_select("captcha", "*", "imagehash = '{$imagehash}' AND {$field} = '{$imagestring}'");
$imgcheck = $db->fetch_array($query);





			if(!$imgcheck)
{
$this->set_error($lang->invalid_captcha_verify);
$db->delete_query("captcha", "imagehash = '{$imagehash}'");

			if(!$imgcheck)
{
$this->set_error($lang->invalid_captcha_verify);
$db->delete_query("captcha", "imagehash = '{$imagehash}'");

			}

			}

		}
elseif(in_array($this->type, array(4, 5)))
{
$response = $mybb->input['g-recaptcha-response'];

		}
elseif(in_array($this->type, array(4, 5)))
{
$response = $mybb->input['g-recaptcha-response'];

			if(!$response || strlen($response) == 0)
{


































			if(!$response || strlen($response) == 0)
{
$this->set_error($lang->invalid_nocaptcha);
}
else
{
// We have a noCAPTCHA or reCAPTCHA invisible to handle
// Contact Google and see if our reCAPTCHA was successful
$response = fetch_remote_file($this->verify_server, array(
'secret' => $mybb->settings['recaptchaprivatekey'],
'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')
{
// We got it wrong! Oh no...
$this->set_error($lang->invalid_nocaptcha);
}
}
}
}
elseif($this->type == 8)
{
$response = $mybb->input['g-recaptcha-response'];
if(!$response || strlen($response) == 0)
{

				$this->set_error($lang->invalid_nocaptcha);
}
else
{

				$this->set_error($lang->invalid_nocaptcha);
}
else
{

				// We have a noCAPTCHA or reCAPTCHA invisible to handle
// Contact Google and see if our reCAPTCHA was successful



































				// We have a reCAPTCHA invisible to handle
// Contact Google and see if our reCAPTCHA was successful
$response = fetch_remote_file($this->verify_server, array(
'secret' => $mybb->settings['recaptchaprivatekey'],
'score' => $mybb->settings['recaptchascore'],
'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' || $answer['score'] < $mybb->settings['recaptchascore'])
{
// We got it wrong! Oh no...
$this->set_error($lang->invalid_nocaptcha);
}
}
}
}
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 handle
// Contact hCaptcha and see if our hCaptcha was successful

				$response = fetch_remote_file($this->verify_server, array(

				$response = fetch_remote_file($this->verify_server, array(

					'secret' => $mybb->settings['captchaprivatekey'],

					'secret' => $mybb->settings['hcaptchaprivatekey'],

					'remoteip' => $session->ipaddress,
'response' => $response
));

if($response == false)
{

					'remoteip' => $session->ipaddress,
'response' => $response
));

if($response == false)
{

					$this->set_error($lang->invalid_nocaptcha_transmit);

					$this->set_error($lang->invalid_hcaptcha_transmit);

				}
else
{
$answer = json_decode($response, true);

				}
else
{
$answer = json_decode($response, true);



 
					if($answer['success'] != 'true')
{
// We got it wrong! Oh no...

					if($answer['success'] != 'true')
{
// We got it wrong! Oh no...

						$this->set_error($lang->invalid_nocaptcha);

						$this->set_error($lang->invalid_hcaptcha);

					}
}
}
}

					}
}
}
}



 
		$plugins->run_hooks('captcha_validate_end', $this);

if(count($this->errors) > 0)

		$plugins->run_hooks('captcha_validate_end', $this);

if(count($this->errors) > 0)