twSblamPlugin - 0.0.2

Antispam validator plugin

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

twSblam plugin

The twSblamPlugin is antispam validator plugin. It uses Sblam antispam system to validate message. Is much better front line check system than Captcha. Captcha can be used as second test if SBLAM say propablu SPAM or SPAM to not angry users using to much links in their posts dor example.

Sblam project site is now only in Polish version but if someone help translate this site I think that lead developer of this project will be happy.

Installation

  • Install the plugin

    $ symfony plugin:install twSblamPlugin
    

Instructions

You can use Sblam Validator class like normal validator

Example

lib/form/SblamTestForm.class.php

    class SblamTestForm extends sfForm {
        public function configure() {
            $this->setWidgets(array(
                'name'    => new sfWidgetFormInputText(),
                'email'   => new sfWidgetFormInputText(),
                'message' => new sfWidgetFormTextarea(),
                'www'     => new sfWidgetFormInputText(),
            ));

            $this->widgetSchema->setNameFormat('blogpost[%s]');

            $this->setValidators(array(
                'name'    => new sfValidatorString(array('required' => false)),
                'email'   => new sfValidatorEmail(array('required' => false, 'trim' => true)),
                'message' => new sfValidatorString(array('min_length' => 4, 'trim' => true)),
                'www'     => new sfValidatorUrl(array('required' => false, 'trim' => true)),
            ));

            $this->validatorSchema->setPostValidator(new sfValidatorSblam(array('blogpost' => array('message', 'name', 'email', 'www')), 'zwxkS5pDST8v8qdd8e', sfValidatorSblam::PROBABLY_SPAM));

        }
    }

In upper example Validator will react where SBLAm returns sfValidatorSblam::PROBABLY_SPAM or sfValidatorSblam::SPAM (result >= 1)

You can chose list of types when Validator react's:

    $this->validatorSchema->setPostValidator(new sfValidatorSblam(array('blogpost' => array('message', 'name', 'email', 'www')), 'zwxkS5pDST8v8qdd8e', array(sfValidatorSblam::SPAM, sfValidatorSblam::SERVER_ERROR)));

modules/testform/actions/action.class.php

    class testformActions extends sfActions {
        public function executeIndex(sfWebRequest $request) {
            $this->form = new SblamTestForm();
            if ($request->isMethod('post')) {
                $this->form->bind($request->getParameter('blogpost'));
                if ($this->form->isValid()) {
                    $this->redirect('testform/ok');
                }
            }
        }

        public function executeOk(sfWebRequest $request) {
        }
    }

Changelog

2010-03-07 | 0.0.1 Alpha

  • ldath: Initial version

2010-03-16 | 0.0.2 Alpha

  • ldath: rewriting SBLAM client php file for better use with symfony
  • ldath: first validator version