cleantalk/yii-antispam
Composer 安装命令:
composer require cleantalk/yii-antispam
包简介
Anti-spam yii extension by CleanTalk with protection against spam bots and manual spam.
README 文档
README
Yii-antispam
Anti-spam by CleanTalk extension with protection against spam bots and manual spam.
No Captcha, no questions, no counting animals, no puzzles, no math.
If you find this project useful, please consider starring ⭐ it on GitHub — it helps us grow and support development!
Requirements
- Yii 1.1 or above
- CleanTalk account https://cleantalk.org/register?product=anti-spam
Websites that trust CleanTalk!
##Usage
-
Get access key on https://cleantalk.org/register?platform=yii
-
Extract content from archive under protected/extensions/yii-antispam
-
Open your application configuration in protected/config/main.php and modify components section:
// application components
'components'=>array(
...
'cleanTalk'=>array(
'class'=>'ext.yii-antispam.CleanTalkApi',
'apiKey'=>'*****',
),
...
),
- Add validator in your model, for example 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 */),
...
);
}
...
}
- In form view add special hidden element
<?php $form=$this->beginWidget('CActiveForm', array(
...
<?php echo Yii::app()->cleanTalk->checkJsHiddenField()?>
...
<?php echo CHtml::submitButton('Submit'); ?>
...
<?php $this->endWidget(); ?>
##License GNU General Public License
##Resources
统计信息
- 总下载量: 1.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 16
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2014-06-18