- GetValidate (100,30 );
-
- Function getValidate ($ w, $ h ){
- $ Img = imagecreate ($ w, $ h );
-
- $ Gray = imagecolorallocate ($ img, 255,255,255 );
- $ Black = imagecolorallocate ($ img, rand (0,200), rand (0,200), rand (0,200 ));
- $ Red = imagecolorallocate ($ img, 255, 0, 0 );
- $ White = imagecolorallocate ($ img, 255,255,255 );
- $ Green = imagecolorallocate ($ img, 0,255, 0 );
- $ Blue = imagecolorallocate ($ img, 0, 0,255 );
- Imagefilledrectangle ($ img, 0, 0,100, 30, $ black );
-
-
- For ($ I = 0; $ I <80; $ I ++ ){
- Imagesetpixel ($ img, rand (0, $ w), rand (0, $ h), $ gray );
- }
-
-
- $ Num1 = rand (1, 99 );
- $ Num2 = rand (1, 99 );
-
- Imagestring ($ img, 5, 5, rand (1, 10), $ num1, $ red );
- Imagestring ($ img, 5, 30, rand (1, 10), getRand (), $ white );
- Imagestring ($ img, 5, 45, rand (1, 10), $ num2, $ green );
- Imagestring ($ img, 5, 65, rand (1, 10), "=", $ blue );
- Imagestring ($ img, 5, 80, rand (1, 10 ),"? ", $ Red );
-
-
- Header ("content-type: image/png ");
- Imagepng ($ img );
- Imagedestroy ($ img );
- }
- Function getRand (){
- $ Code = rand (0, 1 );
- Switch ($ code ){
- Case 0:
- Return "+ ";
- Break;
- Case 1:
- Return "-";
- Break;
- Default:
- # Code...
- Break;
- }
- }
-
- ?>
|