Changeset 3032

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

Pulling riddles from i18n file now. Inverted basic style to generate dark text on a light background. Clear difference from alpha style now.

Location:
trunk/system
Files:
4 modified

Legend:

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

    r3031 r3032  
    1919$config['default'] = array 
    2020( 
    21         'style'           => 'alpha', 
     21        'style'           => 'basic', 
    2222        'width'           => 150, 
    2323        'height'          => 50, 
  • trunk/system/i18n/en_US/captcha.php

    r3028 r3032  
    1919                'architect', 'president', 'cockroach', 'encounter', 'terrorism', 'cylinders', 
    2020        ), 
     21 
     22        // Riddles for the Captcha_Riddle_Driver to pick from 
     23        // Note: use only alphanumeric characters 
     24        'riddles' => array 
     25        ( 
     26                array('Do you hate spam? (yes or no)', 'yes'), 
     27                array('Are you a robot? (yes or no)', 'no'), 
     28                array('Fire is... (hot or cold)', 'hot'), 
     29                array('The season after fall is...', 'winter'), 
     30                array('Which day of the week is it today?', strftime('%A')), 
     31                array('Which month of the year are we in?', strftime('%B')), 
     32        ), 
    2133); 
  • trunk/system/libraries/drivers/Captcha/Basic.php

    r3031 r3032  
    3535 
    3636                // Add a random gradient 
    37                 $color1 = imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); 
    38                 $color2 = imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); 
     37                $color1 = imagecolorallocate($this->image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255)); 
     38                $color2 = imagecolorallocate($this->image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255)); 
    3939                $this->image_gradient($color1, $color2); 
    4040 
     
    4242                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(50, 120)); 
    45                         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); 
     44                        $color = imagecolorallocatealpha($this->image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(100, 255), mt_rand(50, 120)); 
     45                        imageline($this->image, mt_rand(0, Captcha::$config['width']), 0, mt_rand(0, Captcha::$config['width']), Captcha::$config['height'], $color); 
    4646                } 
    4747 
     
    5454                { 
    5555                        // Allocate random color, size and rotation attributes to text 
    56                         $color = imagecolorallocate($this->image, mt_rand(150, 255), mt_rand(200, 255), mt_rand(0, 255)); 
     56                        $color = imagecolorallocate($this->image, mt_rand(0, 150), mt_rand(0, 150), mt_rand(0, 150)); 
    5757                        $angle = mt_rand(-40, 20); 
    5858 
  • trunk/system/libraries/drivers/Captcha/Riddle.php

    r3024 r3032  
    1212class Captcha_Riddle_Driver extends Captcha_Driver { 
    1313 
    14         private $question; 
     14        private $riddle; 
    1515 
    1616        /** 
     
    2121        public function generate_challenge() 
    2222        { 
    23                 // TODO: pull random riddle from i18n file 
    24                 //       make a selection based on complexity setting? 
    25                 $riddles = array 
    26                 ( 
    27                         array 
    28                         ( 
    29                                 'Do you hate spam? (yes or no)', 
    30                                 'yes' 
    31                         ), 
    32                         array 
    33                         ( 
    34                                 'Fire is... (hot or cold)', 
    35                                 'hot' 
    36                         ), 
    37                         array 
    38                         ( 
    39                                 'Which day of the week is it today?', 
    40                                 strftime('%A') 
    41                         ), 
    42                 ); 
     23                // Load riddles from the current language 
     24                $riddles = Kohana::lang('captcha.riddles'); 
    4325 
    44                 // Pick a riddle 
     26                // Pick a random riddle 
    4527                $riddle = $riddles[array_rand($riddles)]; 
    4628 
    4729                // Store the question for output 
    48                 $this->question = $riddle[0]; 
     30                $this->riddle = $riddle[0]; 
    4931 
    5032                // Return the answer 
     
    6042        public function render($html) 
    6143        { 
    62                 return $this->question; 
     44                return $this->riddle; 
    6345        } 
    6446