cleantalk / yii-antispam
CleanTalk提供的反垃圾邮件yii扩展,具有防止垃圾邮件爬虫和人工垃圾邮件的功能。
1.1.0
2015-08-30 11:42 UTC
Requires
- php: >=5.3.0
- yiisoft/yii: 1.1.*
Requires (Dev)
- phpunit/phpunit: ~4.1
This package is auto-updated.
Last update: 2024-09-12 09:54:44 UTC
README
## Yii-antispam CleanTalk提供的反垃圾邮件扩展,具有防止垃圾邮件爬虫和人工垃圾邮件的功能。
无需验证码、无需回答问题、无需计数动物、无需解谜、无需数学计算。
要求
- Yii 1.1或更高版本
- CleanTalk账户 https://cleantalk.org/register?product=anti-spam
##使用方法
-
将存档中的内容提取到protected/extensions/yii-antispam目录下
-
打开您的应用程序配置文件protected/config/main.php并修改components部分
// application components
'components'=>array(
...
'cleanTalk'=>array(
'class'=>'ext.yii-antispam.CleanTalkApi',
'apiKey'=>'*****',
),
...
),
- 在您的模型中添加验证器,例如ContactForm
class ContactForm extends CFormModel
{
public $name;
public $email;
public $body;
...
public function rules()
{
return array(
...
array('body',
'ext.yii-antispam.CleanTalkValidator',
'check'=>'message', /* Check type message or user */
'emailAttribute'=>'email',
'nickNameAttribute'=>'name',
/*'on'=>'insert' if ActiveRecord using */),
...
);
}
...
}
- 在表单视图中添加特殊隐藏元素
<?php $form=$this->beginWidget('CActiveForm', array(
...
<?php echo Yii::app()->cleanTalk->checkJsHiddenField()?>
...
<?php echo CHtml::submitButton('Submit'); ?>
...
<?php $this->endWidget(); ?>
##许可证 GNU通用公共许可证
##资源