domingosjunior87/honeypot-captcha

CakePHP 2.x 的插件,用于使用 HoneyPot Captcha

安装: 880

依赖: 0

建议者: 0

安全: 0

星星: 0

关注者: 1

分支: 0

类型:cakephp-plugin

0.1.3 2017-09-12 13:38 UTC

This package is not auto-updated.

Last update: 2024-09-29 04:25:57 UTC


README

CakePHP 2.x 的插件,用于使用 HoneyPot Captcha

要求

  • PHP 5.3+
  • CakePHP 2.X

安装

在您的应用目录中输入

composer require domingosjunior87/honeypot-captcha

设置

在 app/Config/bootstrap.php 中添加

CakePlugin::load('HoneypotCaptcha');

用法

在控制器中,导入组件和助手,如下所示

public $components = array(
    'HoneypotCaptcha.Honeypot' => array(
        'text' => array('email_user', 'email_admin'),
        'checkbox' => array('validate_submit', 'validate_form'),
        'hidden' => array('phone_number'),
        'errorMessage' => "Error message"
    )
);

public $helpers = array('HoneypotCaptcha.Honeypot');

在视图中,只需这样,在表单标签内

echo $this->Honeypot->render();

当提交表单时,验证数据

if (!$this->Honeypot->validate()) {
	return $this->redirect(array('action' => 'index'));
}