Changeset 3028

Show
Ignore:
Timestamp:
07/10/2008 08:33:05 AM (3 months ago)
Author:
Geert
Message:

Captcha_Word_Driver added. It picks a word from the list you supply in the captcha i18n file.

What's also cool to note is that the Captcha_Word_Driver extends the Captcha_Basic_Driver and completely inherits its render() method. :)

Location:
trunk/system
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/config/captcha.php

    r3024 r3028  
    88 * 
    99 * Group Options: 
    10  *  style           - Captcha type, e.g. basic, math, riddle 
     10 *  style           - Captcha type, e.g. basic, word, math, riddle 
    1111 *  width           - Width of the Captcha image 
    1212 *  height          - Height of the Captcha image 
    13  *  complexity      - Difficulty of the Captcha, concrete usage depends on chosen style 
     13 *  complexity      - Difficulty level (0-10), usage depends on chosen style 
    1414 *  background_path - Path to folder in which background image reside 
    1515 *  background_file - Image file name 
  • trunk/system/i18n/en_US/captcha.php

    r2753 r3028  
    55        'file_not_found' => 'The specified file, %s, was not found. Please verify that files exist by using file_exists() before using them.', 
    66        'requires_GD2'   => 'The Captcha library requires GD2 with FreeType support. Please see http://php.net/gd_info for more information.', 
     7 
     8        // Words of varying length for the Captcha_Word_Driver to pick from 
     9        // Note: use only alphanumeric characters 
     10        'words' => array 
     11        ( 
     12                'cd', 'tv', 'it', 'to', 'be', 'or', 
     13                'sun', 'car', 'dog', 'bed', 'kid', 'egg', 
     14                'bike', 'tree', 'bath', 'roof', 'road', 'hair', 
     15                'hello', 'world', 'earth', 'beard', 'chess', 'water', 
     16                'barber', 'bakery', 'banana', 'market', 'purple', 'writer', 
     17                'america', 'release', 'playing', 'working', 'foreign', 'general', 
     18                'aircraft', 'computer', 'laughter', 'alphabet', 'kangaroo', 'spelling', 
     19                'architect', 'president', 'cockroach', 'encounter', 'terrorism', 'cylinders', 
     20        ), 
    721); 
  • trunk/system/libraries/drivers/Captcha/Basic.php

    r3027 r3028  
    4747 
    4848                // Calculate character font-size and spacing 
    49                 $default_size = min(Captcha::$config['width'], Captcha::$config['height'] * 2) / strlen(Captcha::$answer); 
     49                $default_size = min(Captcha::$config['width'], Captcha::$config['height'] * 2) / (strlen(Captcha::$answer) + 1); 
    5050                $spacing = (int) (Captcha::$config['width'] * 0.9 / strlen(Captcha::$answer)); 
    5151