Changeset 3445 for branches/2.2/security/captcha.php
- Timestamp:
- 11/01/10 09:13:03 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/security/captcha.php
r3444 r3445 91 91 imagecolortransparent($image,$bgcolor); 92 92 93 function hex2int($image, $color) { 94 $string = str_replace("#","",$color); 95 $red = hexdec(substr($string,0,2)); 96 $green = hexdec(substr($string,2,2)); 97 $blue = hexdec(substr($string,4,2)); 93 98 94 $src = imagecreatefrompng('captcha_images/img00'.rand(1,4).'.png'); 99 $color_int = imagecolorallocate($image, $red, $green, $blue); 100 return($color_int); 101 } 102 // create a blank image 103 $src = imagecreatetruecolor(151, 37); 104 105 // fill the background color 106 imagefill($src, 0, 0, hex2int($src, "FFFFFF") ); 107 108 109 /* Put some elipses */ 110 for ($i=0; $i < 5; $i++) 111 { 112 $col_ellipse = imagecolorallocate($src, rand (60,255), rand(60,255), rand(60, 255)); 113 imagefilledellipse($src, rand(1,150), rand(1,50), rand(10,30), rand(10,30), $col_ellipse); 114 } 115 116 /* Put some vertical lines*/ 117 for ($i=0; $i < 5; $i++) 118 { 119 $xr = rand(0,130); 120 $yr = rand(0,40); 121 imagefilledrectangle($src, $xr, $yr, $xr+100, $yr+1, rand(0,255)); 122 } 123 124 /*Put some horizontal lines*/ 125 for ($i=0; $i < 5; $i++) 126 { 127 $xr = rand(0,130); 128 $yr = rand(0,40); 129 imagefilledrectangle($src, $xr, $yr, $xr+1, $yr+100, rand(0,255)); 130 } 131 95 132 imagecopymerge($image, $src, 0, 0, 0, 0, 151, 37, 25); 96 133
Note: See TracChangeset
for help on using the changeset viewer.