Vergleich inc/class_captcha.php - 1.8.5 - 1.8.6

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 60Zeile 60
	 * @var string
*/
public $server = '';

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


/**
* CAPTCHA Secure Server URL
*
* @var string
*/
public $secure_server = '';

 

/**
* CAPTCHA Verify Server


/**
* CAPTCHA Verify Server

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

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


/**


/**

	 * Are You a Human configuration
*
* @var string

	 * Are You a Human configuration
*
* @var string

Zeile 88Zeile 81

/**
* HTML of the built CAPTCHA


/**
* HTML of the built CAPTCHA

	 *

	 *

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

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

Zeile 99Zeile 92
	 * @var array
*/
public $errors = array();

	 * @var array
*/
public $errors = array();








/**
* @param bool $build
* @param string $template
*/

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

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





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

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





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

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





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

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





		// Prepare the build template
if($template)
{
$this->captcha_template = $template;

		// Prepare the build template
if($template)
{
$this->captcha_template = $template;





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

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

Zeile 150Zeile 147
		else if($this->type == 2 && $mybb->settings['captchapublickey'] && $mybb->settings['captchaprivatekey'])
{
// We want to use reCAPTCHA, set the server options

		else if($this->type == 2 && $mybb->settings['captchapublickey'] && $mybb->settings['captchaprivatekey'])
{
// We want to use reCAPTCHA, set the server options

			$this->server = "http://www.google.com/recaptcha/api";
$this->secure_server = "https://www.google.com/recaptcha/api";

			$this->server = "//www.google.com/recaptcha/api";


			$this->verify_server = "www.google.com";

if($build == true)

			$this->verify_server = "www.google.com";

if($build == true)

Zeile 162Zeile 158
		else if($this->type == 4 && $mybb->settings['captchapublickey'] && $mybb->settings['captchaprivatekey'])
{
// We want to use reCAPTCHA, set the server options

		else if($this->type == 4 && $mybb->settings['captchapublickey'] && $mybb->settings['captchaprivatekey'])
{
// We want to use reCAPTCHA, set the server options

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

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


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

if($build == true)

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

if($build == true)

Zeile 176Zeile 171
			if(!function_exists("imagecreatefrompng"))
{
// We want to use the default CAPTCHA, but it's not installed

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

				return false;

				return;

			}
else if($build == true)
{

			}
else if($build == true)
{

Zeile 187Zeile 182
		$plugins->run_hooks('captcha_build_end', $args);
}


		$plugins->run_hooks('captcha_build_end', $args);
}


 
	/**
* @param bool $return Not used
*/

	function build_captcha($return = false)

	function build_captcha($return = false)

	{

	{

		global $db, $lang, $templates, $theme, $mybb;

// This will build a MyBB CAPTCHA

		global $db, $lang, $templates, $theme, $mybb;

// This will build a MyBB CAPTCHA

Zeile 205Zeile 203
		eval("\$this->html = \"".$templates->get($this->captcha_template)."\";");
//eval("\$this->html = \"".$templates->get("member_register_regimage")."\";");
}

		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
$server = $this->server;
$public_key = $mybb->settings['captchapublickey'];

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


if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
{
// Use secure server if HTTPS
$server = $this->secure_server;
}

 

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

Zeile 245Zeile 237
		}
}


		}
}


 
	/**
* @return string
*/

	function build_hidden_captcha()
{
global $db, $mybb, $templates;

$field = array();

	function build_hidden_captcha()
{
global $db, $mybb, $templates;

$field = array();





		if($this->type == 1)
{
// Names
$hash = "imagehash";
$string = "imagestring";

		if($this->type == 1)
{
// Names
$hash = "imagehash";
$string = "imagestring";





			// Values
$field['hash'] = $db->escape_string($mybb->input['imagehash']);
$field['string'] = $db->escape_string($mybb->input['imagestring']);
}
else if($this->type == 2)

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

			// Names
$hash = "recaptcha_challenge_field";
$string = "recaptcha_response_field";

Zeile 274Zeile 269
		else if($this->type == 3)
{
// Are You a Human can't be built as a hidden captcha

		else if($this->type == 3)
{
// Are You a Human can't be built as a hidden captcha

			continue;

			return '';

		}

eval("\$this->html = \"".$templates->get("post_captcha_hidden")."\";");
return $this->html;
}


		}

eval("\$this->html = \"".$templates->get("post_captcha_hidden")."\";");
return $this->html;
}


 
	/**
* @return bool
*/

	function validate_captcha()
{
global $db, $lang, $mybb, $session, $plugins;

	function validate_captcha()
{
global $db, $lang, $mybb, $session, $plugins;

Zeile 292Zeile 290
			// We have a normal CAPTCHA to handle
$imagehash = $db->escape_string($mybb->input['imagehash']);
$imagestring = $db->escape_string(my_strtolower($mybb->input['imagestring']));

			// We have a normal CAPTCHA to handle
$imagehash = $db->escape_string($mybb->input['imagehash']);
$imagestring = $db->escape_string(my_strtolower($mybb->input['imagestring']));





			switch($db->type)
{
case 'mysql':
case 'mysqli':
$field = 'imagestring';

			switch($db->type)
{
case 'mysql':
case 'mysqli':
$field = 'imagestring';

					break;

					break;

				default:
$field = 'LOWER(imagestring)';
break;

				default:
$field = 'LOWER(imagestring)';
break;

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

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

				}
else

				}
else

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

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

Zeile 366Zeile 364
					{
// We got it wrong! Oh no...
$this->set_error($lang->invalid_captcha_verify);

					{
// We got it wrong! Oh no...
$this->set_error($lang->invalid_captcha_verify);

					}

					}

				}
}
}

				}
}
}

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

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





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

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

Zeile 400Zeile 398
						// We got it wrong! Oh no...
$this->set_error($lang->invalid_nocaptcha);
}

						// We got it wrong! Oh no...
$this->set_error($lang->invalid_nocaptcha);
}

				}
}
}

				}
}
}

		elseif($this->type == 3)
{
define('AYAH_PUBLISHER_KEY', $this->ayah_publisher_key);

		elseif($this->type == 3)
{
define('AYAH_PUBLISHER_KEY', $this->ayah_publisher_key);

Zeile 415Zeile 413
			$ayah = new AYAH();

$result = $ayah->scoreResult();

			$ayah = new AYAH();

$result = $ayah->scoreResult();





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

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

			}
}

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

			}
}

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


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


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

Zeile 454Zeile 452

/**
* Add an error to the error array.


/**
* Add an error to the error array.

 
	 *
* @param string $error
* @param string $data

	 */
function set_error($error, $data='')
{

	 */
function set_error($error, $data='')
{

Zeile 467Zeile 468
	 * Returns the error(s) that occurred when handling data
* in a format that MyBB can handle.
*

	 * Returns the error(s) that occurred when handling data
* in a format that MyBB can handle.
*

	 * @return An array of errors in a MyBB format.

	 * @return array An array of errors in a MyBB format.

	 */
function get_errors()
{
global $lang;


	 */
function get_errors()
{
global $lang;


 
		$errors = array();

		foreach($this->errors as $error)
{
$lang_string = $error['error_code'];

		foreach($this->errors as $error)
{
$lang_string = $error['error_code'];

Zeile 514Zeile 516
		return $errors;
}


		return $errors;
}


 
	/**
* @param array $data
*
* @return string
*/

	private function _qsencode($data)
{
$req = '';

	private function _qsencode($data)
{
$req = '';