captcha-extended CaptchaExtended enhances original captcha delivered with framework by implementing logical phrases and visual elements.

  1. Features
  2. Demo
  3. Requirements
  4. Installation and usage
  5. Changelog
  6. Version 1.0.3 Feb 19, 2021
  7. Version 1.0.2 Sept 19, 2013
  8. Version 1.0.1 July 01, 2012
  9. Version 1.0.0 August 29, 2011

This documentation applies to Yii 1.X framework version. For Yii2 please use yii2-captcha-extended.

Captcha Extended enhances original captcha implementation supplied with the framework by adding more visual masking techniques and implementing logical phrases that are harder to break by spammers.

Features

  • supports modes: logical, words, mathverbal, math, default
  • supports extended characters latin1, latin2 (utf-8) including middle- east- European and cyrillic characters
  • implements masking elements: dots density, through lines, fillSections, font color varying
  • ignorant to whitespaces
  • supports case sensitivity / insensitivity even for non-latin1 characters for client side validation

Demo

Screenshot

Screenshot

Screenshot

Requirements

This extension will run right out of the box on Yii 1.1.7+ However, with minor tweaks you can run it on any previous version (uses $classmap and enableClientValidation introduced in 1.1.7, you can replace class registration e.g. with importing whole directory, which however is less performance wise).

Installation and usage

1) Unzip CaptchaExtended.zip files into ../protected/extensions/captchaExtended/.

2) Register class paths to CaptchaExtendedAction and CaptchaExtendedValidator, e.g. in components/controller.php:

public function init(){
		// register class paths for extension captcha extended
		Yii::$classMap = array_merge( Yii::$classMap, array(
			'CaptchaExtendedAction' => Yii::getPathOfAlias('ext.captchaExtended').DIRECTORY_SEPARATOR.'CaptchaExtendedAction.php',
			'CaptchaExtendedValidator' => Yii::getPathOfAlias('ext.captchaExtended').DIRECTORY_SEPARATOR.'CaptchaExtendedValidator.php'
		));
	}

3) Define action in controller, e.g. SiteController:

public function actions(){
		return array(
			'captcha'=>array(
				'class'=>'CaptchaExtendedAction',
				// if needed, modify settings
				'mode'=>CaptchaExtendedAction::MODE_MATH,
			),
		);
	}

4) Define client validation in model::rules():

public function rules(){
		return array(
			array('verifyCode', 'CaptchaExtendedValidator', 'allowEmpty'=>!CCaptcha::checkRequirements()),
		);
	}

5) If needed, collect localized strings via CLI command "yiic message messages/config.php" and translate captcha related strings.

6) If needed, you can tune captcha modes and visibility options:

  • In "words" mode, you can place your own file [words.txt] or [words.yourlanguage.txt]
  • If needed, you can ..
    • set the dots density [0-100]
    • the number of through lines 0, 1, 2, ..
    • the number of fillSections 0, 1, 2, ..
    • font and background colors

7) Test & enjoy!

Changelog

Version 1.0.3 Feb 19, 2021

  • fixed compatability issues for PHP 7.4+ (e.g. imagecolorallocate accepts only valid range 0-255)
  • fixed calculation of centered position for text inside image
  • added support for parameter "regenerateOnValid", default TRUE
  • optimized some default settings e.g. font size, number of lines or dots density

Version 1.0.2 Sept 19, 2013

  • bugfix: skip captcha counter incrementation if clientajax validation is turned on. Otherwise captcha code would be silently invalidated after entering as many form fields as the number of allowed captcha attempts.

Version 1.0.1 July 01, 2012

  • fixed client-side validation that generated incorrect validation hash.
  • Fixed issue with UTF-8 accented lowercase characters and filtering whitespaces.

Version 1.0.0 August 29, 2011

  • Initial release