azt3k / abc-silverstripe-textcap
基于文本的 SilverStripe 验证码模块
0.1.1
2015-05-13 02:09 UTC
Requires
- php: >=5.3.0
- composer/installers: >=1.0
- silverstripe/cms: >=3.1
- silverstripe/framework: >=3.1
This package is not auto-updated.
Last update: 2024-09-24 05:58:47 UTC
README
- 将以下内容添加到您的 composer.json 文件中
"require": { "azt3k/abc-silverstripe-textcap" : "*@stable" }
-
运行
composer install -
访问
http://textcaptcha.com/并注册 API 密钥(现在这是可选的) -
配置 API 密钥(现在这是可选的)
将以下内容插入到您的 project/_config.php 文件中,将 your-api-key 替换为第 3 步中获得的 API 密钥
AbcTextCap::set_text_captcha_api_key('your-api-key');
- 或者 -
将以下内容插入到您的 project/_config/config.yml 文件中
AbcTextCap: text_captcha_api_key: your-api-key
- 将验证码字段添加到您的表单中
<?php class ContactForm extends Form { public function __construct($controller, $name){ $fields = new FieldList; $fields->push(new TextField('Name', 'Your Name')); $fields->push(new EmailField('Email', 'Your Email')); $fields->push(new TextField('Subject')); $fields->push(new TextareaField('Message', 'Message')); $fields->push(new AbcTextCapField('Captcha','Are you a human?')); // Actions $actions = new FieldList(new FormAction("doProcessForm", 'Send')); // Validator $required = new RequiredFields('Name', 'Email', 'Captcha'); // Construct parent::__construct($controller, $name, $fields, $actions, $required); } public function doProcessForm($data, $form){ // default success value $success = false; // load the data $form->loadDataFrom($data); // validate using existing validators if ($valid = $form->validate()) { // save a record etc } if (!$valid) $form->sessionMessage("Sorry there were some problems with your submission", 'bad'); else $form->sessionMessage("Your message has been sent", 'good'); // go back to the last location $this->Controller()->redirectBack(); return; } }
许可协议
版权 (c) 2018 Aaron Latham-Ilari
版权所有。
在不违反以下免责声明中的限制条件下,允许(修改或未修改)重新分配和使用,前提是满足以下条件
- 源代码的重新分配必须保留上述版权声明、本条件列表和以下免责声明。
- 二进制形式的重新分配必须在文档和/或其他提供的材料中复制上述版权声明、本条件列表和以下免责声明。
- 未经[所有者组织]的明确书面许可,不得使用其名称或其贡献者的名称来认可或推广由此软件衍生出的产品。
本许可协议未授予任何一方对任何专利权利的明确或默示许可。本软件由版权所有者和贡献者“按原样”提供,不承担任何明示或暗示的保证,包括但不限于适销性和针对特定目的的适用性保证。在任何情况下,版权所有者或贡献者不应对任何直接、间接、偶然、特殊、示范性或后果性损害(包括但不限于替代商品或服务的采购;使用、数据或利润的损失;或业务中断)承担责任,即使被告知此类损害的可能性也是如此。