Added feature #12714: Add TS constants to control darkness of the captcha text. Thank...
authorstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Wed, 2 Feb 2011 04:12:45 +0000 (04:12 +0000)
committerstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Wed, 2 Feb 2011 04:12:45 +0000 (04:12 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/sr_freecap/trunk@42951 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
doc/manual.sxw
ext_typoscript_constants.txt
ext_typoscript_setup.txt
pi1/class.tx_srfreecap_pi1.php

index 6958fd9..0e3e7fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-02-01  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Added feature #12714: Add TS constants to control darkness of the captcha text. Thanks to Julia Pardanaud.
+
 2010-12-21  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #10223: BE module not shown anymore with TYPO3 4.4
 2010-12-21  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #10223: BE module not shown anymore with TYPO3 4.4
index ac23634..5f79d6e 100644 (file)
Binary files a/doc/manual.sxw and b/doc/manual.sxw differ
index 45ceaaf..c677b6d 100644 (file)
@@ -18,6 +18,12 @@ plugin.tx_srfreecap {
     # cat=plugin.tx_srfreecap/color; type=boolean; label= Color of the text: 0=one random colour for all letters, 1=different random colour for each letter.
        textColor = 1
 
     # cat=plugin.tx_srfreecap/color; type=boolean; label= Color of the text: 0=one random colour for all letters, 1=different random colour for each letter.
        textColor = 1
 
+    # cat=plugin.tx_srfreecap/color; type=int[0-255]; label= Maximum darkness of the text color: The lower the number, the darker the color of the text be may.
+       colorMaximumDarkness = 5
+
+    # cat=plugin.tx_srfreecap/color; type=int[0-255]; label= Maximum lightness of the text color: The higher the number, the lighter the color of the text be may.
+       colorMaximumLightness = 50
+
     # cat=plugin.tx_srfreecap//03; type=options[png,gif,jpg]; label= CAPTCHA image format: Format of the generated image.
        imageFormat = png
 
     # cat=plugin.tx_srfreecap//03; type=options[png,gif,jpg]; label= CAPTCHA image format: Format of the generated image.
        imageFormat = png
 
index f247991..a2aa61e 100644 (file)
@@ -14,7 +14,9 @@ plugin.tx_srfreecap_pi1 {
        maxWordLength = {$plugin.tx_srfreecap.maxWordLength}
        useWordsList = {$plugin.tx_srfreecap.useWordsList}
        generateNumbers = {$plugin.tx_srfreecap.generateNumbers}
        maxWordLength = {$plugin.tx_srfreecap.maxWordLength}
        useWordsList = {$plugin.tx_srfreecap.useWordsList}
        generateNumbers = {$plugin.tx_srfreecap.generateNumbers}
-       
+
+       colorMaximumDarkness = {$plugin.tx_srfreecap.colorMaximumDarkness}
+       colorMaximumLightness = {$plugin.tx_srfreecap.colorMaximumLightness}
        textColor = {$plugin.tx_srfreecap.textColor}
        mergeWithBackground = {$plugin.tx_srfreecap.mergeWithBackground}
        morphFactor = {$plugin.tx_srfreecap.morphFactor}
        textColor = {$plugin.tx_srfreecap.textColor}
        mergeWithBackground = {$plugin.tx_srfreecap.mergeWithBackground}
        morphFactor = {$plugin.tx_srfreecap.morphFactor}
index b66cb09..45d2f4b 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2005-2009 Stanislas Rolland (typo3(arobas)sjbr.ca)
+*  (c) 2005-2011 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -213,6 +213,14 @@ class tx_srfreecap_pi1 extends tslib_pibase {
                // text morh factor
                $this->morphFactor = $this->conf['morphFactor'] ? $this->conf['morphFactor'] : 1;
                
                // text morh factor
                $this->morphFactor = $this->conf['morphFactor'] ? $this->conf['morphFactor'] : 1;
                
+               // Limits for text colour
+               if (isset($this->conf['colorMaximumDarkness'])) {
+                       $this->colorMaximumDarkness = intval($this->conf['colorMaximumDarkness']);
+               }
+               if (isset($this->conf['colorMaximumLightness'])) {
+                       $this->colorMaximumLightness = intval($this->conf['colorMaximumLightness']);
+               }
+               
                // should we blur the background? (looks nicer, makes text easier to read, takes longer)
                $this->blur_bg = $this->conf['backgroundBlur'] ? true : false;
                
                // should we blur the background? (looks nicer, makes text easier to read, takes longer)
                $this->blur_bg = $this->conf['backgroundBlur'] ? true : false;
                
@@ -355,10 +363,13 @@ class tx_srfreecap_pi1 extends tslib_pibase {
        function rand_color() {
                if($this->bg_type==3) {
                        // needs darker colour..
        function rand_color() {
                if($this->bg_type==3) {
                        // needs darker colour..
-                       return $this->rand_func(10,100);
+                       $colorMaximumDarkness = isset($this->colorMaximumDarkness) ? $this->colorMaximumDarkness : 10;
+                       $colorMaximumLightness = isset($this->colorMaximumLightness) ? $this->colorMaximumLightness : 100;
                } else {
                } else {
-                       return $this->rand_func(60,170);
+                       $colorMaximumDarkness = isset($this->colorMaximumDarkness) ? $this->colorMaximumDarkness : 30;
+                       $colorMaximumLightness = isset($this->colorMaximumLightness) ? $this->colorMaximumLightness : 140;
                }
                }
+               return $this->rand_func($colorMaximumDarkness, $colorMaximumLightness);
        }
 
        function hash_func($string) {
        }
 
        function hash_func($string) {