Giter Club home page Giter Club logo

yii2-antispam's Introduction

Anti-spam extension by CleanTalk for Yii2 framework.

No Captcha, no questions, no counting animals, no puzzles, no math.

Build Status

Requirements

##Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist cleantalk/yii2-antispam

or add

"cleantalk/yii2-antispam": "~1.0.0"

to the require section of your composer.json.

##Usage

  1. Get access key on https://cleantalk.org/register?platform=yii2

  2. Open your application configuration in protected/config/web.php and modify components section:

// application components
'components'=>[
    ...
        'antispam' => [
            'class' => 'cleantalk\antispam\Component',
            'apiKey' => 'Your API KEY',
        ],
    ...
],
  1. Add validator in your model, for example ContactForm:
namespace app\models;

use cleantalk\antispam\validators\MessageValidator;
use Yii;
use yii\base\Model;

/**
 * ContactForm is the model behind the contact form.
 */
class ContactForm extends Model
{
    public $name;
    public $email;
    public $body;
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            // name, email, subject and body are required
            [['name', 'email', 'subject', 'body'], 'required'],
            // email has to be a valid email address
            ['email', 'email'],
            ['body', MessageValidator::className(), 'emailAttribute'=>'email', /*'nickNameAttribute'=>'name'*/]
        ];
    }
}
  1. In form view add widget for hidden Javascript checks:
<?php $form = ActiveForm::begin(); ?>
    ...
    <?= \cleantalk\antispam\Widget::widget()?>
    ...
    <?= Html::submitButton('Submit')?>
    ...
<?php ActiveForm::end(); ?>

User registration validator

See cleantalk\antispam\validators\UserValidator

Example rules:

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'email'], 'required'],
            ['email', 'email'],
            ['email', UserValidator::className(), 'nickNameAttribute'=>'name']
        ];
    }

##License GNU General Public License

##Resources

yii2-antispam's People

Contributors

artemanoshin avatar psrustik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

yii2-antispam's Issues

Implemented cleantalk for registration but not working

added below in user model
['email', UserValidator::className(), 'nickNameAttribute'=>'username']

added below in registration view

register with email "[email protected]" as it is listed spam on cleantalk but get registered in my application.

show entry on cleantalk server as spam but in my application still get registered
Please help !!
cleantalk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.