- session_start();
-
- //生成验证码图片
-
- Header("Content-type: image/PNG");
-
- srand((double)microtime()*1000000);
-
- $im = imagecreate(62,20);
-
- $black = ImageColorAllocate($im, 69,120,239);
-
- $white = ImageColorAllocate($im, 0,0,0);
-
- $gray = ImageColorAllocate($im, 200,200,200);
-
- imagefill($im,68,30,$gray);
-
- while(($authnum=rand()%100000)
- //将五位整数验证码绘入图片
-
- imagestring($im, 5, 10, 3, $authnum, $white);
-
- for($i=0;$i
- {
-
- $randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
-
- imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
-
- }
- ImagePNG($im);
- ImageDestroy($im);
- $_SESSION['SESSION_VALIDATE_CODE'] = $authnum.'';
-
- ?>
-
-
-
- $txt="memory";
- $im = imagecreatetruecolor(400,30);
- $white = ImageColorAllocate($im, 255,255,255);
- $black = ImageColorAllocate($im, 0,0,0);
-
- // Replace path by your own font path
- imagestring($im,1,10,10,$txt,$black);
- //imagettftext($im, 20, 0, 10, 20, $black, "font.ttf","Testing...");
- header("Content-type:image/jpeg");
- imagejpeg($im);
- // imagedestroy($im);
-
-
复制代码
|