<无详细内容>
- Session_start ();
- // Generate a verification code Image
- Header ("Content-type: image/PNG ");
- Srand (double) microtime () * 1000000 );
- $ Im = imagecreate (62,20 );
- $ Black = ImageColorAllocate ($ im, 69,120,239 );
- $ White = ImageColorAllocate ($ im, 0, 0 );
- $ Gray = ImageColorAllocate ($ im, 200,200,200 );
- Imagefill ($ im, 68, 30, $ gray );
- While ($ authnum = rand () % 100000) <10000 );
- // Print the five-digit integer verification code into the image
- Imagestring ($ im, 5, 10, 3, $ authnum, $ white );
- For ($ I = 0; $ I <200; $ I ++) // add interference pixels
- {
- $ 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 );
- // 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 );
|