Zeile 48 | Zeile 48 |
---|
* @var int */ public $type = 0;
|
* @var int */ public $type = 0;
|
| /** * CAPTCHA constants declaration * * @var int */ const DEFAULT_CAPTCHA = 1; const NOCAPTCHA_RECAPTCHA = 4; const RECAPTCHA_INVISIBLE = 5; const HCAPTCHA = 6; const HCAPTCHA_INVISIBLE = 7; const RECAPTCHA_V3 = 8;
|
/** * The template to display the CAPTCHA in
| /** * The template to display the CAPTCHA in
|
Zeile 107 | Zeile 119 |
---|
{ $this->captcha_template = $template;
|
{ $this->captcha_template = $template;
|
if($this->type == 4)
| if($this->type == captcha::NOCAPTCHA_RECAPTCHA)
|
{ $this->captcha_template .= "_nocaptcha"; }
|
{ $this->captcha_template .= "_nocaptcha"; }
|
elseif($this->type == 5)
| elseif($this->type == captcha::RECAPTCHA_INVISIBLE)
|
{ $this->captcha_template .= "_recaptcha_invisible"; }
|
{ $this->captcha_template .= "_recaptcha_invisible"; }
|
elseif($this->type == 6)
| elseif($this->type == captcha::HCAPTCHA)
|
{ $this->captcha_template .= "_hcaptcha"; }
|
{ $this->captcha_template .= "_hcaptcha"; }
|
elseif($this->type == 7)
| elseif($this->type == captcha::HCAPTCHA_INVISIBLE)
|
{ $this->captcha_template .= "_hcaptcha_invisible"; }
|
{ $this->captcha_template .= "_hcaptcha_invisible"; }
|
elseif($this->type == 8)
| elseif($this->type == captcha::RECAPTCHA_V3)
|
{ $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, 8)) && $mybb->settings['recaptchapublickey'] && $mybb->settings['recaptchaprivatekey'])
| if(in_array($this->type, array(captcha::NOCAPTCHA_RECAPTCHA, captcha::RECAPTCHA_INVISIBLE, captcha::RECAPTCHA_V3)) && $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";
| { // We want to use noCAPTCHA or reCAPTCHA invisible, set the server options $this->server = "//www.google.com/recaptcha/api.js";
|
Zeile 141 | Zeile 153 |
---|
$this->build_recaptcha(); } }
|
$this->build_recaptcha(); } }
|
elseif(in_array($this->type, array(6, 7)) && $mybb->settings['hcaptchapublickey'] && $mybb->settings['hcaptchaprivatekey'])
| elseif(in_array($this->type, array(captcha::HCAPTCHA, captcha::HCAPTCHA_INVISIBLE)) && $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";
| { // We want to use hCaptcha or hCaptcha invisible, set the server options $this->server = "//www.hcaptcha.com/1/api.js";
|
Zeile 152 | Zeile 164 |
---|
$this->build_hcaptcha(); } }
|
$this->build_hcaptcha(); } }
|
elseif($this->type == 1)
| elseif($this->type == captcha::DEFAULT_CAPTCHA)
|
{ if(!function_exists("imagecreatefrompng")) {
| { if(!function_exists("imagecreatefrompng")) {
|
Zeile 224 | Zeile 236 |
---|
$field = array();
|
$field = array();
|
if($this->type == 1)
| if($this->type == captcha::DEFAULT_CAPTCHA)
|
{ // Names $hash = "imagehash"; $string = "imagestring";
// Values
|
{ // Names $hash = "imagehash"; $string = "imagestring";
// Values
|
$field['hash'] = $db->escape_string($mybb->input['imagehash']); $field['string'] = $db->escape_string($mybb->input['imagestring']);
| $field['hash'] = $db->escape_string($mybb->get_input('imagehash')); $field['string'] = $db->escape_string($mybb->get_input('imagestring'));
|
} elseif($this->type == 3) {
| } elseif($this->type == 3) {
|
Zeile 253 | Zeile 265 |
---|
$plugins->run_hooks('captcha_validate_start', $this);
|
$plugins->run_hooks('captcha_validate_start', $this);
|
if($this->type == 1)
| if($this->type == captcha::DEFAULT_CAPTCHA)
|
{ // We have a normal CAPTCHA to handle
|
{ // We have a normal CAPTCHA to handle
|
$imagehash = $db->escape_string($mybb->input['imagehash']); $imagestring = $db->escape_string(my_strtolower($mybb->input['imagestring']));
| $imagehash = $db->escape_string($mybb->get_input('imagehash')); $imagestring = $db->escape_string(my_strtolower($mybb->get_input('imagestring')));
|
switch($db->type) {
| switch($db->type) {
|
Zeile 279 | Zeile 291 |
---|
$db->delete_query("captcha", "imagehash = '{$imagehash}'"); } }
|
$db->delete_query("captcha", "imagehash = '{$imagehash}'"); } }
|
elseif(in_array($this->type, array(4, 5)))
| elseif(in_array($this->type, array(captcha::NOCAPTCHA_RECAPTCHA, captcha::RECAPTCHA_INVISIBLE)))
|
{
|
{
|
$response = $mybb->input['g-recaptcha-response'];
| $response = $mybb->get_input('g-recaptcha-response');
|
if(!$response || strlen($response) == 0) { $this->set_error($lang->invalid_nocaptcha);
| if(!$response || strlen($response) == 0) { $this->set_error($lang->invalid_nocaptcha);
|
Zeile 312 | Zeile 324 |
---|
} } }
|
} } }
|
elseif($this->type == 8)
| elseif($this->type == captcha::RECAPTCHA_V3)
|
{
|
{
|
$response = $mybb->input['g-recaptcha-response'];
| $response = $mybb->get_input('g-recaptcha-response');
|
if(!$response || strlen($response) == 0) { $this->set_error($lang->invalid_nocaptcha);
| if(!$response || strlen($response) == 0) { $this->set_error($lang->invalid_nocaptcha);
|
Zeile 346 | Zeile 358 |
---|
} } }
|
} } }
|
elseif(in_array($this->type, array(6, 7)))
| elseif(in_array($this->type, array(captcha::HCAPTCHA, captcha::HCAPTCHA_INVISIBLE)))
|
{
|
{
|
$response = $mybb->input['h-captcha-response'];
| $response = $mybb->get_input('h-captcha-response');
|
if(!$response || strlen($response) == 0) { $this->set_error($lang->invalid_hcaptcha);
| if(!$response || strlen($response) == 0) { $this->set_error($lang->invalid_hcaptcha);
|
Zeile 394 | Zeile 406 |
---|
{ global $db, $mybb, $plugins;
|
{ global $db, $mybb, $plugins;
|
if($this->type == 1)
| if($this->type == captcha::DEFAULT_CAPTCHA)
|
{ // We have a normal CAPTCHA to handle
|
{ // We have a normal CAPTCHA to handle
|
$imagehash = $db->escape_string($mybb->input['imagehash']);
| $imagehash = $db->escape_string($mybb->get_input('imagehash'));
|
if($imagehash) { $db->delete_query("captcha", "imagehash = '{$imagehash}'");
| if($imagehash) { $db->delete_query("captcha", "imagehash = '{$imagehash}'");
|