Vergleich inc/class_captcha.php - 1.8.6 - 1.8.23

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

	 * Type of CAPTCHA.
*
* 1 = Default CAPTCHA

	 * 2 = reCAPTCHA
* 3 = Are You a Human

 
	 * 4 = NoCATPCHA reCAPTCHA

	 * 4 = NoCATPCHA reCAPTCHA

 
	 * 5 = reCAPTCHA invisible
* 6 = hCaptcha
* 7 = hCaptcha invisible
* 8 = reCAPTCHA v3

	 *
* @var int
*/

	 *
* @var int
*/

Zeile 52Zeile 54
	 *
* @var string
*/

	 *
* @var string
*/

	 public $captch_template = '';

	 public $captcha_template = '';


/**
* CAPTCHA Server URL


/**
* CAPTCHA Server URL

Zeile 67Zeile 69
	 * @var string
*/
public $verify_server = '';

	 * @var string
*/
public $verify_server = '';


/**
* Are You a Human configuration
*
* @var string
*/
public $ayah_web_service_host = '';
public $ayah_publisher_key = '';
public $ayah_scoring_key = '';
public $ayah_debug_mode = '';
public $ayah_use_curl = '';

 

/**
* HTML of the built CAPTCHA
*
* @var string


/**
* HTML of the built CAPTCHA
*
* @var string

	 */

	 */

	public $html = '';

	public $html = '';


/**


/**

	 * The errors that occurred when handling data.
*
* @var array

	 * The errors that occurred when handling data.
*
* @var array

	 */

	 */

	public $errors = array();

/**

	public $errors = array();

/**

Zeile 100Zeile 91
	function __construct($build = false, $template = "")
{
global $mybb, $plugins;

	function __construct($build = false, $template = "")
{
global $mybb, $plugins;





		$this->type = $mybb->settings['captchaimage'];

$args = array(
'this' => &$this,
'build' => &$build,
'template' => &$template,

		$this->type = $mybb->settings['captchaimage'];

$args = array(
'this' => &$this,
'build' => &$build,
'template' => &$template,

		);

		);


$plugins->run_hooks('captcha_build_start', $args);



$plugins->run_hooks('captcha_build_start', $args);


Zeile 115Zeile 106
		if($template)
{
$this->captcha_template = $template;

		if($template)
{
$this->captcha_template = $template;


if($this->type == 2)
{
$this->captcha_template .= "_recaptcha";
}
else if($this->type == 3)


if($this->type == 4)





			{

			{

				$this->captcha_template .= "_ayah";

				$this->captcha_template .= "_nocaptcha";

			}

			}

			else if($this->type == 4){
$this->captcha_template .= "_nocaptcha";
}
}

// Work on which CAPTCHA we've got installed
if($this->type == 3 && $mybb->settings['ayahpublisherkey'] && $mybb->settings['ayahscoringkey'])
{
// We want to use Are You a Human, set configuration options
$this->ayah_web_service_host = "ws.areyouahuman.com";
$this->ayah_publisher_key = $mybb->settings['ayahpublisherkey'];
$this->ayah_scoring_key = $mybb->settings['ayahscoringkey'];
$this->ayah_debug_mode = false;
$this->ayah_use_curl = true;

if($build == true)

			elseif($this->type == 5)
















			{

			{

				$this->build_ayah();

				$this->captcha_template .= "_recaptcha_invisible";

			}

			}

		}
else if($this->type == 2 && $mybb->settings['captchapublickey'] && $mybb->settings['captchaprivatekey'])
{
// We want to use reCAPTCHA, set the server options
$this->server = "//www.google.com/recaptcha/api";
$this->verify_server = "www.google.com";

if($build == true)

			elseif($this->type == 6)








			{

			{

				$this->build_recaptcha();









				$this->captcha_template .= "_hcaptcha";
}
elseif($this->type == 7)
{
$this->captcha_template .= "_hcaptcha_invisible";
}
elseif($this->type == 8)
{
$this->captcha_template .= "_recaptcha_invisible";

			}
}

			}
}

		else if($this->type == 4 && $mybb->settings['captchapublickey'] && $mybb->settings['captchaprivatekey'])




// Work on which CAPTCHA we've got installed
if(in_array($this->type, array(4, 5, 8)) && $mybb->settings['recaptchapublickey'] && $mybb->settings['recaptchaprivatekey'])

		{

		{

			// We want to use reCAPTCHA, set the server options

			// 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";


			$this->server = "//www.google.com/recaptcha/api.js";
$this->verify_server = "https://www.google.com/recaptcha/api/siteverify";


Zeile 166Zeile 141
				$this->build_recaptcha();
}
}

				$this->build_recaptcha();
}
}

		else if($this->type == 1)












		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)

		{
if(!function_exists("imagecreatefrompng"))
{
// We want to use the default CAPTCHA, but it's not installed
return;
}

		{
if(!function_exists("imagecreatefrompng"))
{
// We want to use the default CAPTCHA, but it's not installed
return;
}

			else if($build == true)

			elseif($build == true)

			{
$this->build_captcha();
}

			{
$this->build_captcha();
}

Zeile 210Zeile 196

// This will build a reCAPTCHA
$server = $this->server;


// This will build a reCAPTCHA
$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("member_register_regimage_recaptcha")."\";");
}



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


	function build_ayah()

	function build_hcaptcha()

	{
global $lang, $mybb, $templates;


	{
global $lang, $mybb, $templates;


		define('AYAH_PUBLISHER_KEY', $this->ayah_publisher_key);
define('AYAH_SCORING_KEY', $this->ayah_scoring_key);
define('AYAH_USE_CURL', $this->ayah_use_curl);
define('AYAH_DEBUG_MODE', $this->ayah_debug_mode);
define('AYAH_WEB_SERVICE_HOST', $this->ayah_web_service_host);

require_once MYBB_ROOT."inc/3rdparty/ayah/ayah.php";
$ayah = new AYAH();
$output = $ayah->getPublisherHTML();

if(!empty($output))
{
eval("\$this->html = \"".$templates->get($this->captcha_template, 1, 0)."\";");
//eval("\$this->html = \"".$templates->get("member_register_regimage_ayah")."\";");
}

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









	}

/**

	}

/**

Zeile 256Zeile 234
			$field['hash'] = $db->escape_string($mybb->input['imagehash']);
$field['string'] = $db->escape_string($mybb->input['imagestring']);
}

			$field['hash'] = $db->escape_string($mybb->input['imagehash']);
$field['string'] = $db->escape_string($mybb->input['imagestring']);
}

		else if($this->type == 2)
{
// Names
$hash = "recaptcha_challenge_field";
$string = "recaptcha_response_field";

// Values
$field['hash'] = $mybb->input['recaptcha_challenge_field'];
$field['string'] = $mybb->input['recaptcha_response_field'];
}
else if($this->type == 3)

		elseif($this->type == 3)











		{
// Are You a Human can't be built as a hidden captcha
return '';

		{
// Are You a Human can't be built as a hidden captcha
return '';

Zeile 309Zeile 277
			{
$this->set_error($lang->invalid_captcha_verify);
$db->delete_query("captcha", "imagehash = '{$imagehash}'");

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

			}
}
elseif($this->type == 2)
{
$challenge = $mybb->input['recaptcha_challenge_field'];
$response = $mybb->input['recaptcha_response_field'];

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
































			}
}
elseif(in_array($this->type, array(4, 5)))
{
$response = $mybb->input['g-recaptcha-response'];
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_captcha);

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

			}
else

			}
else

			{
// We have a reCAPTCHA to handle
$data = $this->_qsencode(array(
'privatekey' => $mybb->settings['captchaprivatekey'],



			{
// 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,

					'remoteip' => $session->ipaddress,

					'challenge' => $challenge,

 
					'response' => $response
));


					'response' => $response
));


				// Contact Google and see if our reCAPTCHA was successful
$http_request = "POST /recaptcha/api/verify HTTP/1.0\r\n";
$http_request .= "Host: $this->verify_server\r\n";
$http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
$http_request .= "Content-Length: ".strlen($data)."\r\n";
$http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
$http_request .= "\r\n";
$http_request .= $data;

$fs = @fsockopen($this->verify_server, 80, $errno, $errstr, 10);

if($fs == false)
{
$this->set_error($lang->invalid_captcha_transmit);

				if($response === false)
{
$this->set_error($lang->invalid_nocaptcha_transmit);












				}
else
{

				}
else
{

					// We connected, but is it correct?
fwrite($fs, $http_request);

					$answer = json_decode($response, true);






					while(!feof($fs))
{
$response .= fgets($fs, 1160);
}

fclose($fs);

$response = explode("\r\n\r\n", $response, 2);
$answer = explode("\n", $response[1]);

if(trim($answer[0]) != 'true')

					if($answer['success'] != 'true' || $answer['score'] < $mybb->settings['recaptchascore'])











					{
// We got it wrong! Oh no...

					{
// We got it wrong! Oh no...

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

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

					}
}
}
}

					}
}
}
}

		elseif($this->type == 4)

		elseif(in_array($this->type, array(6, 7)))

		{

		{

			$response = $mybb->input['g-recaptcha-response'];

			$response = $mybb->input['h-captcha-response'];

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

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

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

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

			}
else
{

			}
else
{

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

				// 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
));

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





				if($response == false)

				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);

					}
}
}
}

					}
}
}
}

		elseif($this->type == 3)
{
define('AYAH_PUBLISHER_KEY', $this->ayah_publisher_key);
define('AYAH_SCORING_KEY', $this->ayah_scoring_key);
define('AYAH_USE_CURL', $this->ayah_use_curl);
define('AYAH_DEBUG_MODE', $this->ayah_debug_mode);
define('AYAH_WEB_SERVICE_HOST', $this->ayah_web_service_host);

require_once MYBB_ROOT."inc/3rdparty/ayah/ayah.php";
$ayah = new AYAH();

$result = $ayah->scoreResult();

if($result == false)
{
$this->set_error($lang->invalid_ayah_result);
}
}


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

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

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

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