diff --git a/build/gulp-extensions.json b/build/gulp-extensions.json index 9e837363e903..fd16ef33fbc1 100644 --- a/build/gulp-extensions.json +++ b/build/gulp-extensions.json @@ -10,7 +10,7 @@ }, "plugins" : { "redform" : ["economic", "helpscout", "redmemberbillinginfo", "salesforce", "aesirmember", "aesirecommerce"], - "redform_captcha" : ["hiddencaptcha", "recaptcha", "simplemath"], + "redform_captcha" : ["hiddencaptcha", "recaptcha", "simplemath", "hcaptcha"], "redform_field" : [ "dawa", "acymailing", diff --git a/build/joomla-gulp-extensions/plugins/redform_captcha/hcaptcha.js b/build/joomla-gulp-extensions/plugins/redform_captcha/hcaptcha.js new file mode 100644 index 000000000000..b7c175c7d37e --- /dev/null +++ b/build/joomla-gulp-extensions/plugins/redform_captcha/hcaptcha.js @@ -0,0 +1,7 @@ +var base = require('../baseplugin'); +var path = require('path'); + +var name = path.basename(__filename).replace('.js', ''); +var group = path.basename(path.dirname(__filename)); + +base.addPlugin(group, name); diff --git a/plugins/redform_captcha/hcaptcha/hcaptcha.php b/plugins/redform_captcha/hcaptcha/hcaptcha.php new file mode 100644 index 000000000000..d1848012f3cc --- /dev/null +++ b/plugins/redform_captcha/hcaptcha/hcaptcha.php @@ -0,0 +1,79 @@ +addScript('https://hcaptcha.com/1/api.js', [], ['defer' => true, 'async' => true]); + + $attributes = [ + 'data-sitekey' => $this->params->get('siteKey'), + 'data-theme' => $this->params->get('theme', 'light'), + 'data-size' => $this->params->get('size', 'normal'), + ]; + + $text = '
'; + + return true; + } + + /** + * onCheckCaptcha trigger + * + * @param bool &$result result + * + * @return bool + */ + public function onCheckCaptcha(&$result) + { + $app = Factory::getApplication(); + $input = $app->input; + $response = $input->post->getString('h-captcha-response'); + $result = false; + + if (empty($response)) + { + return $result; + } + + try + { + $response = HttpFactory::getHttp() + ->post( + 'https://hcaptcha.com/siteverify', + [ + 'secret' => $this->params->get('secretKey'), + 'response' => $response, + 'sitekey' => $this->params->get('siteKey'), + 'remoteip' => $input->server->get('REMOTE_ADDR') + ] + ); + + $responseData = json_decode($response->body); + $result = $responseData->success; + } + catch (Exception $e) + { + } + + return $result; + } +} diff --git a/plugins/redform_captcha/hcaptcha/hcaptcha.xml b/plugins/redform_captcha/hcaptcha/hcaptcha.xml new file mode 100644 index 000000000000..c94b3d00863d --- /dev/null +++ b/plugins/redform_captcha/hcaptcha/hcaptcha.xml @@ -0,0 +1,49 @@ + + + PLG_REDFORM_CAPTCHA_HCAPTCHA + December 8, 2020 + redWEB Aps + email@redweb.dk + www.redcomponent.com + (C) 2008 - 2020 redCOMPONENT.com + GNU/GPL + 1.0.0 + PLG_REDFORM_CAPTCHA_HCAPTCHA_XML_DESCRIPTION + + hcaptcha.php + language + + + +
+ + + + + + + + + + +
+
+
+
diff --git a/plugins/redform_captcha/hcaptcha/language/en-GB/en-GB.plg_redform_captcha_hcaptcha.ini b/plugins/redform_captcha/hcaptcha/language/en-GB/en-GB.plg_redform_captcha_hcaptcha.ini new file mode 100644 index 000000000000..f6ccdcd994ff --- /dev/null +++ b/plugins/redform_captcha/hcaptcha/language/en-GB/en-GB.plg_redform_captcha_hcaptcha.ini @@ -0,0 +1,12 @@ +PLG_REDFORM_CAPTCHA_HCAPTCHA="redFORM hcaptcha plugin" +PLG_REDFORM_CAPTCHA_HCAPTCHA_XML_DESCRIPTION="hcaptcha plugin for redform" +PLG_REDFORM_CAPTCHA_HCAPTCHA_SITE_KEY="Site key" +PLG_REDFORM_CAPTCHA_HCAPTCHA_SITE_KEY_DESC="Enter please site key" +PLG_REDFORM_CAPTCHA_HCAPTCHA_SECRET_KEY="Secret key" +PLG_REDFORM_CAPTCHA_HCAPTCHA_SECRET_KEY_DESC="Enter please secret key" +PLG_REDFORM_CAPTCHA_HCAPTCHA_THEME="Theme" +PLG_REDFORM_CAPTCHA_HCAPTCHA_THEME_LIGHT="Light" +PLG_REDFORM_CAPTCHA_HCAPTCHA_THEME_DARK="Dark" +PLG_REDFORM_CAPTCHA_HCAPTCHA_SIZE="Size" +PLG_REDFORM_CAPTCHA_HCAPTCHA_SIZE_NORMAL="Normal" +PLG_REDFORM_CAPTCHA_HCAPTCHA_SIZE_COMPACT="Compact" \ No newline at end of file diff --git a/plugins/redform_captcha/hcaptcha/language/en-GB/en-GB.plg_redform_captcha_hcaptcha.sys.ini b/plugins/redform_captcha/hcaptcha/language/en-GB/en-GB.plg_redform_captcha_hcaptcha.sys.ini new file mode 100644 index 000000000000..680eb2e374be --- /dev/null +++ b/plugins/redform_captcha/hcaptcha/language/en-GB/en-GB.plg_redform_captcha_hcaptcha.sys.ini @@ -0,0 +1,2 @@ +PLG_REDFORM_CAPTCHA_HCAPTCHA="redFORM hcaptcha plugin" +PLG_REDFORM_CAPTCHA_HCAPTCHA_XML_DESCRIPTION="hcaptcha plugin for redform"