diff --git a/README.md b/README.md index 812e4a4..ea21b6a 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,8 @@ Plugin name is "wildwolf/recaptcha" $rcmail_config['recaptcha_public_key'] = 'sitekey form https://www.google.com/recaptcha/admin'; $rcmail_config['recaptcha_secret_key'] = 'secret from https://www.google.com/recaptcha/admin'; $rcmail_config['recaptcha_theme'] = 'dark or light'; + +// Set this option to true to have the login button disabled, Until +// the user clicks the checkbox to pass the reCAPTCHA test. +$rcmail_config['auto_disable'] = true; ``` diff --git a/config.inc.php.dist b/config.inc.php.dist index 7dd52c1..2e35f86 100644 --- a/config.inc.php.dist +++ b/config.inc.php.dist @@ -3,4 +3,8 @@ // See https://developers.google.com/recaptcha/docs/display $rcmail_config['recaptcha_public_key'] = ''; $rcmail_config['recaptcha_secret_key'] = ''; -$rcmail_config['recaptcha_theme'] = 'dark'; \ No newline at end of file +$rcmail_config['recaptcha_theme'] = 'dark'; + +// Set this option to true to have the login button disabled, Until +// the user clicks the checkbox to pass the reCAPTCHA test. +$rcmail_config['auto_disable'] = true; diff --git a/recaptcha.php b/recaptcha.php index eff8b80..090b3ff 100644 --- a/recaptcha.php +++ b/recaptcha.php @@ -5,7 +5,7 @@ class recaptcha extends rcube_plugin public function init() { $this->load_config(); - + $this->include_script('recaptcha.js'); $rcmail = rcmail::get_instance(); if ($rcmail->config->get('recaptcha_public_key') != '' && $rcmail->config->get('recaptcha_secret_key') != '') { $this->add_hook('template_object_loginform', [$this, 'template_object_loginform']); @@ -25,10 +25,18 @@ public function template_object_loginform(array $loginform) : array $loginform['content'] = str_ireplace( '', - '
', + '
', $loginform['content'] ); + if($rcmail->config->get('auto_disable')) { + $loginform['content'] = str_ireplace( + '', + '', + $loginform['content'] + ); + } + return $loginform; }