Php verification code generation program [automatically determines the php gd Library]
Function ShowKey ()
{
$ Key = strtolower (domake_password (4 ));
$ Set = esetcookie ("checkkey", $ key );
// Whether the gd Library is supported
If (function_exists ("imagejpeg ")){
Header ("Content-type: image/jpeg ");
$ Img = imagecreate (69,20 );
$ Black = imagecolorallocate ($ img, 255,255,255 );
$ Gray = imagecolorallocate ($ img, 102,102,102 );
Imagefill ($ img, 0, 0, $ gray );
Imagestring ($ img, 3,14, 3, $ key, $ black );
Imagejpeg ($ img );
Imagedestroy ($ img );
}
Elseif (function_exists ("imagegif ")){
Header ("Content-type: image/gif ");
$ Img = imagecreate (69,20 );
$ Black = imagecolorallocate ($ img, 255,255,255 );
$ Gray = imagecolorallocate ($ img, 102,102,102 );
Imagefill ($ img, 0, 0, $ gray );
Imagestring ($ img, 3,14, 3, $ key, $ black );
Imagegif ($ img );
Imagedestroy ($ img );
}
Elseif (function_exists ("imagepng ")){
Header ("Content-type: image/png ");
$ Img = imagecreate (69,20 );
$ Black = imagecolorallocate ($ img, 255,255,255 );
$ Gray = imagecolorallocate ($ img, 102,102,102 );
Imagefill ($ img, 0, 0, $ gray );
Imagestring ($ img, 3,14, 3, $ key, $ black );
Imagepng ($ img );
Imagedestroy ($ img );
}
Elseif (function_exists ("imagewbmp ")){
Header ("Content-type: image/vnd. wap. wbmp ");
$ Img = imagecreate (69,20 );
$ Black = imagecolorallocate ($ img, 255,255,255 );
$ Gray = imagecolorallocate ($ img, 102,102,102 );
Imagefill ($ img, 0, 0, $ gray );
Imagestring ($ img, 3,14, 3, $ key, $ black );
Imagewbmp ($ img );
Imagedestroy ($ img );
}
Else {
$ Set = esetcookie ("checkkey", "ebak ");
@ Include ("class/functions. php ");
Echo ReadFiletext ("images/ebak.jpg ");
}
}
ShowKey ();