Show
Ignore:
Timestamp:
07/09/2008 03:45:47 PM (5 months ago)
Author:
Geert
Message:

Revamped Captcha library big time.

  • Each Captcha style has its own driver which generates and renders a Captcha challenge. The output could be an image, but could be anything else since html output is allowed. I included a Riddle driver to give you an idea of the flexibility.
  • Config groups supported.
  • More polished coding style and structure in general.
  • Still needs work on the image generating part. Mostly GD2 stuff, and quite some copy and paste from the previous version. Any help appreciated. :)
Files:
1 modified

Legend:

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

    r2652 r3015  
    11<?php defined('SYSPATH') or die('No direct access allowed.'); 
    22/** 
    3  * @package  Captcha 
     3 * @package  Core 
    44 * 
    5  * Configure the Captcha 
    6  * Custom styles can be added by extending the Captcha class 
     5 * Captcha configuration is defined in groups which allows you to easily switch 
     6 * between different Captcha settings for different forms on your website. 
     7 * Note: all groups inherit and overwrite the default group. 
     8 * 
     9 * Group Options: 
     10 *  style           - Style driver 
     11 *  width           - Width of the Captcha image 
     12 *  height          - Height of the Captcha image 
     13 *  complexity      - Difficulty of the Captcha, concrete usage depends on chosen style 
     14 *  background_path - Path to folder in which background image reside 
     15 *  background_file - Image file name 
     16 *  font_path       - Path to folder in which fonts reside 
     17 *  font_file       - Font file name 
    718 */ 
    8  
    9 /** 
    10  * Width and height of the Captcha image. 
    11  * These settings are ignored if using a background image. 
    12  */ 
    13 $config['width']  = 150; 
    14 $config['height'] = 50; 
    15  
    16 /** 
    17  * Captcha style to use. Default is 'basic' and is only for testing as it 
    18  * does not require any truetype fonts installed. 
    19  * 'standard' is the recommended style. A font must be supplied. A background 
    20  * image is optional. 
    21  * 'alphasoup' is an alternative style. A font must be supplied. 
    22  * 'math' is a 'solve the question' style. 
    23  * A font must be supplied. A background image is optional. 
    24  * Custom styles can be added easily by extending the library. 
    25  */ 
    26 $config['style'] = 'standard'; 
    27  
    28 /** 
    29  * Number of characters to use for the Captcha (4 or 5 recommended). 
    30  * This setting is ignored if using style 'math'. 
    31  */ 
    32 $config['num_chars'] = 4; 
    33  
    34 /** 
    35  * Path to font files. Example: 'application/fonts/'. 
    36  * If using 'standard' style, you must supply a valid truetype font file. 
    37  */ 
    38 $config['font_path'] = SYSPATH.'fonts/'; 
    39  
    40 /** 
    41  * Name of the font, with the file extension. Case sensitive. 
    42  */ 
    43 $config['font_name'] = 'DejaVuSerif.ttf'; 
    44  
    45 /** 
    46  * Background image. Example: 'application/images/pattern.jpg'. 
    47  * The dimensions of this image will be used. 
    48  */ 
    49 $config['background_image'] = ''; 
     19$config['default'] = array 
     20( 
     21        'style'           => 'riddle', 
     22        'width'           => 150, 
     23        'height'          => 50, 
     24        'complexity'      => 4, 
     25        'background_path' => '', 
     26        'background_file' => '', 
     27        'font_path'       => SYSPATH.'fonts/', 
     28        'font_file'       => 'DejaVuSerif.ttf', 
     29);