Vergleich inc/class_captcha.php - 1.8.4 - 1.8.12

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 40Zeile 40
	 *
* 1 = Default CAPTCHA
* 2 = reCAPTCHA

	 *
* 1 = Default CAPTCHA
* 2 = reCAPTCHA

	 * 3 = Are You a Human

 
	 * 4 = NoCATPCHA reCAPTCHA
*
* @var int

	 * 4 = NoCATPCHA reCAPTCHA
*
* @var int

Zeile 52Zeile 51
	 *
* @var string
*/

	 *
* @var string
*/

	 public $captch_template = '';

	 public $captcha_template = '';


/**
* CAPTCHA Server URL


/**
* CAPTCHA Server URL

Zeile 60Zeile 59
	 * @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 66
	 * @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 = '';

/**

Zeile 99Zeile 80
	 * @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,

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

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

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

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

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

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

Zeile 133Zeile 114
		}

// Work on which CAPTCHA we've got installed

		}

// Work on which CAPTCHA we've got installed

		if($this->type == 3 && $mybb->settings['ayahpublisherkey'] && $mybb->settings['ayahscoringkey'])

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

		{

		{

			// 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)
{
$this->build_ayah();
}
}
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->verify_server = "www.google.com";

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


if($build == true)
{

Zeile 162Zeile 128
		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->build_recaptcha();

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

if($build == true)
{
$this->build_recaptcha();

			}
}

			}
}

		else if($this->type == 1)
{
if(!function_exists("imagecreatefrompng"))

		else if($this->type == 1)
{
if(!function_exists("imagecreatefrompng"))

			{

			{

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

				// 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 152
		$plugins->run_hooks('captcha_build_end', $args);
}


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


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

	function build_captcha($return = false)
{
global $db, $lang, $templates, $theme, $mybb;

	function build_captcha($return = false)
{
global $db, $lang, $templates, $theme, $mybb;

Zeile 213Zeile 181
		// 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")."\";");
}


	function build_ayah()
{
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")."\";");
}
}


	/**
* @return string
*/



















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

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

Zeile 274Zeile 218
		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;





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

if($this->type == 1)

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

if($this->type == 1)

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

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

			}

			}


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

Zeile 310Zeile 257
			if(!$imgcheck)
{
$this->set_error($lang->invalid_captcha_verify);

			if(!$imgcheck)
{
$this->set_error($lang->invalid_captcha_verify);

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

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

		}
elseif($this->type == 2)
{

		}
elseif($this->type == 2)
{

Zeile 355Zeile 302
					while(!feof($fs))
{
$response .= fgets($fs, 1160);

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

					}

fclose($fs);


					}

fclose($fs);


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


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


Zeile 366Zeile 313
					{
// 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 388Zeile 335
				));

if($response == false)

				));

if($response == false)

				{

				{

					$this->set_error($lang->invalid_nocaptcha_transmit);
}
else
{
$answer = json_decode($response, true);

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

					if($answer['success'] != 'true')
{
// We got it wrong! Oh no...
$this->set_error($lang->invalid_nocaptcha);
}

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


				}
}
}

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




















		if(count($this->errors) > 0)
{
return false;

		if(count($this->errors) > 0)
{
return false;

		}

		}

		else
{
return true;

		else
{
return true;

		}

		}

	}

function invalidate_captcha()

	}

function invalidate_captcha()

Zeile 454Zeile 383

/**
* 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 399
	 * 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 447
		return $errors;
}


		return $errors;
}


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

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

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