Show
Ignore:
Timestamp:
07/10/2008 11:06:23 AM (5 months ago)
Author:
Geert
Message:

A few minor tweaks to Basic and Alpha Captcha style in order to preserve enough readability and make both styles differ a bit more.

Also changed internal terminology to the "official" convention: http://en.wikipedia.org/wiki/Challenge-response_authentication

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/drivers/Captcha/Basic.php

    r3028 r3031  
    4040 
    4141                // Add a few random lines 
    42                 for ($i = 0, $count = mt_rand(5, 10); $i < $count; $i++) 
     42                for ($i = 0, $count = mt_rand(5, Captcha::$config['complexity'] * 3); $i < $count; $i++) 
    4343                { 
    44                         $color = imagecolorallocatealpha($this->image, mt_rand(100, 255), mt_rand(100, 255), mt_rand(100, 255), mt_rand(60, 120)); 
     44                        $color = imagecolorallocatealpha($this->image, mt_rand(100, 255), mt_rand(100, 255), mt_rand(100, 255), mt_rand(50, 120)); 
    4545                        imageline($this->image, mt_rand(0, Captcha::$config['width']), mt_rand(0, Captcha::$config['height']), mt_rand(0, Captcha::$config['width']), mt_rand(0, Captcha::$config['height']), $color); 
    4646                } 
    4747 
    4848                // Calculate character font-size and spacing 
    49                 $default_size = min(Captcha::$config['width'], Captcha::$config['height'] * 2) / (strlen(Captcha::$answer) + 1); 
    50                 $spacing = (int) (Captcha::$config['width'] * 0.9 / strlen(Captcha::$answer)); 
     49                $default_size = min(Captcha::$config['width'], Captcha::$config['height'] * 2) / (strlen(Captcha::$response) + 1); 
     50                $spacing = (int) (Captcha::$config['width'] * 0.9 / strlen(Captcha::$response)); 
    5151 
    5252                // Draw each Captcha character with varying attributes 
    53                 for ($i = 0, $strlen = strlen(Captcha::$answer); $i < $strlen; $i++) 
     53                for ($i = 0, $strlen = strlen(Captcha::$response); $i < $strlen; $i++) 
    5454                { 
    5555                        // Allocate random color, size and rotation attributes to text 
     
    5959                        // Scale the character size on image height 
    6060                        $size = $default_size / 10 * mt_rand(8, 12); 
    61                         $box = imageftbbox($size, $angle, Captcha::$config['font'], Captcha::$answer[$i]); 
     61                        $box = imageftbbox($size, $angle, Captcha::$config['font'], Captcha::$response[$i]); 
    6262 
    6363                        // Calculate character starting coordinates 
     
    6666 
    6767                        // Write text character to image 
    68                         imagefttext($this->image, $size, $angle, $x, $y, $color, Captcha::$config['font'], Captcha::$answer[$i]); 
     68                        imagefttext($this->image, $size, $angle, $x, $y, $color, Captcha::$config['font'], Captcha::$response[$i]); 
    6969                } 
    7070