Diem plugins syndication

dmMathCaptchaPlugin

A simple and customizable Captcha with arithmetic problems instead of pictures.

Please see documentation. Plugin is tested with 5.1

Installation

  • In a console, from your project root dir, run:
git clone git://github.com/thohms/dmMathCaptchaPlugin.git plugins/dmMathCaptchaPlugin  
  • In config/ProjectConfiguration.class.php, add dmMathCaptchaPlugin to the list of enabled plugins:
class ProjectConfiguration extends dmProjectConfiguration
{  
  public function setup()  
  {  
    parent::setup();  
 
    $this->enablePlugins(array(  
      // your enabled plugins  
      'dmMathCaptchaPlugin'  
    ));  
  • In a console, from your project root dir, run:
php symfony dm:setup  

Introduction

dmMathCaptchaPlugin is a different kind of captcha usually used and is thought as an alternative
to ReCaptcha. For this captcha you don't have to register somewhere and it is much smaller in size
within your forms. Additionaly it is highly customizable (see below).

Widget setup example

To call and use the widget see following example:

$widgetSchema = new dmWidgetFormMathCaptcha();  
$option = $widgetSchema->getOption('mathCaptcha');  

$operator = sfContext::getInstance()->getI18N()->__($option['operatorString']);  

$label = sfContext::getInstance()->getI18N()->__('What is %1% %2% %3%?', array(  
    '%1%' => $option['number1'],  
    '%2%' => $operator,  
    '%3%' => $option['number2']  
));  

$widgetSchema->setLabel($label);  

$this->widgetSchema['mathCaptcha'] = $widgetSchema;  

$this->validatorSchema['mathCaptcha'] = new dmValidatorMathCaptcha();  

** Explanation: **
There are 4 options you can use:
- number1 (randomized integer left from operator)
- number2 (randomized integer right from operator)
- operatorString (randomized operator string as either text or sign)
- result (result of the arithmetic problem - although possible: don't use it in output)

You could also decide to not use I18n, but I would recommend to do so, even for English speakers (see hints why)

I18n

There are 6 strings you can translate. One depends on your own label you have set, the others are:
- plus (is shown if randomized operator is a string and lowercase
- PLUS (same as above just for uppercase)
- minus (same as for plus)
- MINUS (same as for PLUS)
- The result is wrong! (The default error message)
You can find an example for German language in plugin's i18n folder.

Hints

If you choose to use I18n you can enter whatever you want for the arithmetic problem. The above example
would output (if we think of a string operator):

What is 8 plus 3?

Now if you set "together" as translation for "plus" in your i18n file you could do:

What is 8 together with 3?

Some more examples what you could do for giving you some ideas:

Tell me the sum of 8 and 3?
What is 6 subtracted from 3?

... and so on.

You could even randomize the label in your code to make it even harder to get bots finding out your solution
or use words instead of integers.

Have fun with trying out!

    Add a comment

    Create an issue
    Impossible to fetch issues for this plugin.
    Impossible to get this plugin changelog.
    See more commits

    dmMathCaptchaPlugin, created on October 12, 2010 by tohms, used by 35 projects

    Fork Diem on GitHub