Changeset 3076
- Timestamp:
- 07/11/2008 12:53:22 PM (5 months ago)
- Location:
- trunk/system/libraries/drivers
- Files:
-
- 3 modified
-
Captcha.php (modified) (1 diff)
-
Captcha/Alpha.php (modified) (1 diff)
-
Captcha/Basic.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/libraries/drivers/Captcha.php
r3064 r3076 76 76 public function image_create($background = NULL) 77 77 { 78 // Use background image 78 // Create a new image (black) 79 $this->image = imagecreatetruecolor(Captcha::$config['width'], Captcha::$config['height']); 80 81 // Use a background image 79 82 if ( ! empty($background)) 80 83 { 81 $this-> image = $this->image_create_from($background);84 $this->background_image = $this->image_create_from($background); 82 85 83 // Overwrite the dimensions 84 Captcha::$config['width'] = imagesx($this->image); 85 Captcha::$config['height'] = imagesy($this->image); 86 } 87 // Default background (black) 88 else 89 { 90 $this->image = imagecreatetruecolor(Captcha::$config['width'], Captcha::$config['height']); 86 // Resize the image if needed 87 if (imagesx($this->background_image) !== Captcha::$config['width'] 88 OR imagesy($this->background_image) !== Captcha::$config['height']) 89 { 90 imagecopyresampled 91 ( 92 $this->image, $this->background_image, 0, 0, 0, 0, 93 Captcha::$config['width'], Captcha::$config['height'], 94 imagesx($this->background_image), imagesy($this->background_image) 95 ); 96 } 97 98 // Free up resources 99 imagedestroy($this->background_image); 91 100 } 92 101 } -
trunk/system/libraries/drivers/Captcha/Alpha.php
r3031 r3076 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)); 39 $this->image_gradient($color1, $color2); 37 if (empty(Captcha::$config['background'])) 38 { 39 $color1 = imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); 40 $color2 = imagecolorallocate($this->image, mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100)); 41 $this->image_gradient($color1, $color2); 42 } 40 43 41 44 // Add a few random circles -
trunk/system/libraries/drivers/Captcha/Basic.php
r3032 r3076 35 35 36 36 // Add a random gradient 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 $this->image_gradient($color1, $color2); 37 if (empty(Captcha::$config['background'])) 38 { 39 $color1 = imagecolorallocate($this->image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(150, 255)); 40 $color2 = imagecolorallocate($this->image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(150, 255)); 41 $this->image_gradient($color1, $color2); 42 } 40 43 41 44 // Add a few random lines
