Changeset 3032
- Timestamp:
- 07/10/2008 11:31:35 AM (5 months ago)
- Location:
- trunk/system
- Files:
-
- 4 modified
-
config/captcha.php (modified) (1 diff)
-
i18n/en_US/captcha.php (modified) (1 diff)
-
libraries/drivers/Captcha/Basic.php (modified) (3 diffs)
-
libraries/drivers/Captcha/Riddle.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/config/captcha.php
r3031 r3032 19 19 $config['default'] = array 20 20 ( 21 'style' => ' alpha',21 'style' => 'basic', 22 22 'width' => 150, 23 23 'height' => 50, -
trunk/system/i18n/en_US/captcha.php
r3028 r3032 19 19 'architect', 'president', 'cockroach', 'encounter', 'terrorism', 'cylinders', 20 20 ), 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 ), 21 33 ); -
trunk/system/libraries/drivers/Captcha/Basic.php
r3031 r3032 35 35 36 36 // 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)); 39 39 $this->image_gradient($color1, $color2); 40 40 … … 42 42 for ($i = 0, $count = mt_rand(5, Captcha::$config['complexity'] * 3); $i < $count; $i++) 43 43 { 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); 46 46 } 47 47 … … 54 54 { 55 55 // 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)); 57 57 $angle = mt_rand(-40, 20); 58 58 -
trunk/system/libraries/drivers/Captcha/Riddle.php
r3024 r3032 12 12 class Captcha_Riddle_Driver extends Captcha_Driver { 13 13 14 private $ question;14 private $riddle; 15 15 16 16 /** … … 21 21 public function generate_challenge() 22 22 { 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'); 43 25 44 // Pick a r iddle26 // Pick a random riddle 45 27 $riddle = $riddles[array_rand($riddles)]; 46 28 47 29 // Store the question for output 48 $this-> question= $riddle[0];30 $this->riddle = $riddle[0]; 49 31 50 32 // Return the answer … … 60 42 public function render($html) 61 43 { 62 return $this-> question;44 return $this->riddle; 63 45 } 64 46
