From 2d8d9f3b5fdfa115f97f79ba2a85befa3c571281 Mon Sep 17 00:00:00 2001 From: Bogdan Tanase Date: Wed, 13 Mar 2013 12:02:41 +0200 Subject: [PATCH] options to fine tune captcha image: max_front_lines, max_behind_lines --- DependencyInjection/Configuration.php | 2 ++ Generator/CaptchaGenerator.php | 3 +++ README.md | 2 ++ composer.json | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 30f65cb..8e52cd1 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -39,6 +39,8 @@ class Configuration implements ConfigurationInterface ->scalarNode('whitelist_key')->defaultValue('captcha_whitelist_key')->end() ->scalarNode('humanity')->defaultValue(0)->end() ->scalarNode('distortion')->defaultValue(true)->end() + ->scalarNode('max_front_lines')->defaultValue(null)->end() + ->scalarNode('max_behind_lines')->defaultValue(null)->end() ->end() ; diff --git a/Generator/CaptchaGenerator.php b/Generator/CaptchaGenerator.php index bd99ca8..68256b9 100644 --- a/Generator/CaptchaGenerator.php +++ b/Generator/CaptchaGenerator.php @@ -95,6 +95,9 @@ class CaptchaGenerator { $this->builder->setDistortion($options['distortion']); + $this->builder->setMaxFrontLines($options['max_front_lines']); + $this->builder->setMaxBehindLines($options['max_behind_lines']); + $fingerprint = isset($options['fingerprint']) ? $options['fingerprint'] : null; $content = $this->builder->build( diff --git a/README.md b/README.md index 02cbaa0..75610d1 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,8 @@ You can define the following configuration options globally or on the CaptchaTyp * **reload**: adds a link to reload the code * **humanity**: number of extra forms that the user can submit after a correct validation, if set to a value different of 0, only 1 over (1+humanity) forms will contain a CAPTCHA (default=0, i.e each form will contain the CAPTCHA) * **distortion**: enable or disable the distortion on the image (default=true, enabled) +* **max_front_lines**, **max_behind_lines**: the maximum number of lines to draw on top/behind the image. `0` will draw no lines; `null` will use the default algorithm (the +number of lines depends on the size of the image). (default=null) Example : diff --git a/composer.json b/composer.json index 6b01892..9fa731f 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ ], "require": { "php": ">=5.3.0", - "gregwar/captcha": "v1.0.1" + "gregwar/captcha": "v1.0.2" }, "autoload": { "psr-0": {