Zeile 41 | Zeile 41 |
---|
* 1 = Default CAPTCHA * 2 = reCAPTCHA * 3 = Are You a Human
|
* 1 = Default CAPTCHA * 2 = reCAPTCHA * 3 = Are You a Human
|
| * 4 = NoCATPCHA reCAPTCHA
|
* * @var int */
| * * @var int */
|
Zeile 101 | Zeile 102 |
---|
function __construct($build = false, $template = "") {
|
function __construct($build = false, $template = "") {
|
global $mybb;
| global $mybb, $plugins;
|
$this->type = $mybb->settings['captchaimage'];
|
$this->type = $mybb->settings['captchaimage'];
|
| $args = array( 'this' => &$this, 'build' => &$build, 'template' => &$template, );
$plugins->run_hooks('captcha_build_start', $args);
|
// Prepare the build template if($template)
| // Prepare the build template if($template)
|
Zeile 113 | Zeile 122 |
---|
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 == 3) { $this->captcha_template .= "_ayah";
|
| } else if($this->type == 4){ $this->captcha_template .= "_nocaptcha";
|
} }
| } }
|
Zeile 141 | Zeile 153 |
---|
$this->server = "http://www.google.com/recaptcha/api"; $this->secure_server = "https://www.google.com/recaptcha/api"; $this->verify_server = "www.google.com";
|
$this->server = "http://www.google.com/recaptcha/api"; $this->secure_server = "https://www.google.com/recaptcha/api"; $this->verify_server = "www.google.com";
|
| if($build == true) { $this->build_recaptcha(); } } 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->verify_server = "https://www.google.com/recaptcha/api/siteverify";
|
if($build == true) {
| if($build == true) {
|
Zeile 150 | Zeile 174 |
---|
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 return false; } else if($build == true) { $this->build_captcha();
|
// We want to use the default CAPTCHA, but it's not installed return false; } else if($build == true) { $this->build_captcha();
|
} }
// Plugin hook }
| } }
$plugins->run_hooks('captcha_build_end', $args); }
|
function build_captcha($return = false) {
| function build_captcha($return = false) {
|
Zeile 189 | Zeile 213 |
---|
// 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
| if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { // Use secure server if HTTPS
|
Zeile 259 | Zeile 283 |
---|
function validate_captcha() {
|
function validate_captcha() {
|
global $db, $lang, $mybb;
| global $db, $lang, $mybb, $session, $plugins;
|
|
|
// Plugin hook
| $plugins->run_hooks('captcha_validate_start', $this);
|
if($this->type == 1) {
| if($this->type == 1) {
|
Zeile 269 | Zeile 293 |
---|
$imagehash = $db->escape_string($mybb->input['imagehash']); $imagestring = $db->escape_string(my_strtolower($mybb->input['imagestring']));
|
$imagehash = $db->escape_string($mybb->input['imagehash']); $imagestring = $db->escape_string(my_strtolower($mybb->input['imagestring']));
|
$query = $db->simple_select("captcha", "*", "imagehash = '{$imagehash}' AND LOWER(imagestring) = '{$imagestring}'");
| switch($db->type) { case 'mysql': case 'mysqli': $field = 'imagestring'; break; default: $field = 'LOWER(imagestring)'; break; }
$query = $db->simple_select("captcha", "*", "imagehash = '{$imagehash}' AND {$field} = '{$imagestring}'");
|
$imgcheck = $db->fetch_array($query);
if(!$imgcheck)
| $imgcheck = $db->fetch_array($query);
if(!$imgcheck)
|
Zeile 331 | Zeile 366 |
---|
{ // 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);
|
| } } } } elseif($this->type == 4) { $response = $mybb->input['g-recaptcha-response']; if(!$response || strlen($response) == 0) { $this->set_error($lang->invalid_nocaptcha); } else { // We have a noCAPTCHA to handle // Contact Google and see if our reCAPTCHA was successful $response = fetch_remote_file($this->verify_server, array( 'secret' => $mybb->settings['captchaprivatekey'], '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);
|
} } }
| } } }
|
Zeile 354 | Zeile 422 |
---|
} }
|
} }
|
// Plugin hook
| $plugins->run_hooks('captcha_validate_end', $this);
|
if(count($this->errors) > 0) {
| if(count($this->errors) > 0) {
|
Zeile 368 | Zeile 436 |
---|
function invalidate_captcha() {
|
function invalidate_captcha() {
|
global $db, $mybb;
| global $db, $mybb, $plugins;
|
if($this->type == 1) {
| if($this->type == 1) {
|
Zeile 381 | Zeile 449 |
---|
} // Not necessary for reCAPTCHA or Are You a Human
|
} // Not necessary for reCAPTCHA or Are You a Human
|
// Plugin hook
| $plugins->run_hooks('captcha_invalidate_end', $this);
|
}
/**
| }
/**
|