Changeset 3031 for trunk/system/libraries/drivers/Captcha/Basic.php
- Timestamp:
- 07/10/2008 11:06:23 AM (5 months ago)
- Files:
-
- 1 modified
-
trunk/system/libraries/drivers/Captcha/Basic.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/libraries/drivers/Captcha/Basic.php
r3028 r3031 40 40 41 41 // 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++) 43 43 { 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)); 45 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); 46 46 } 47 47 48 48 // 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)); 51 51 52 52 // 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++) 54 54 { 55 55 // Allocate random color, size and rotation attributes to text … … 59 59 // Scale the character size on image height 60 60 $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]); 62 62 63 63 // Calculate character starting coordinates … … 66 66 67 67 // 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]); 69 69 } 70 70
