monsieurbiz/mbiz_invisiblecaptcha

为一些页面添加不可见 ReCaptcha 的 Magento 1 模块。

安装: 398

依赖项: 0

建议者: 0

安全: 0

星标: 11

关注者: 6

分支: 6

公开问题: 1

语言:HTML

类型:magento-module

dev-master 2022-03-22 17:42 UTC

This package is auto-updated.

Last update: 2024-09-22 23:06:06 UTC


README

本模块将 Google 的不可见 ReCaptcha 添加到所有页面,并在联系页面设置验证码。

将 JS 添加到所有页面不是我们的选择,因为这很简单。还因为它大多数时候你会在新闻邮件表单等地方添加验证码。

需求

您需要从 Google 获取 API 密钥:https://www.google.com/recaptcha/admin

PHP >= 5.4

如何工作

您可以在管理面板中设置 API 密钥:系统 > 配置 > 一般 > 不可见验证码

在该页面上,您可以设置您的站点详情,当然您也可以完全禁用验证码。

您还可以选择是否要在某些页面上默认启用它。

自定义表单设置

很简单。

给定以下示例

<form method="post">
    <label>
        My Content
        <input type="text" name="content" />
    </label>
    <button type="submit">Send</button>
</form>

您只需进行少量更改(仅添加)

+<?php
+$_recaptcha = $this->helper('mbiz_invisiblecaptcha');
+?>
+
-<form method="post" id="myForm">
+<form method="post" id="myForm"
+    <?php if ($_recaptcha->isActive()): ?>
+        onsubmit="return captchaMyForm.uiSubmit('<?php echo $_recaptcha->getSiteKey(); ?>', onCaptchaMyFormSubmit, '#g-recaptcha-myform');"
+    <?php endif; ?>
+>
     <label>
         My Content
         <input type="text" name="content" />
     </label>
     <button type="submit">Send</button>
+
+    <?php if ($_recaptcha->isActive()): ?>
+        <div class="g-recaptcha" id="g-recaptcha-myform"></div>
+    <?php endif; ?>
+
 </form>
+
+<?php if ($_recaptcha->isActive()): ?>
+    <script type="text/javascript">
+        //<![CDATA[
+        var captchaMyForm = new MbizInvisibleRecaptchaForm('myForm', true);
+        var onCaptchaMyFormSubmit = captchaMyForm.onSubmit.bind(captchaMyForm);
+        //]]>
+    </script>
+<?php endif; ?>

许可证

LICENSE文件。

贡献者