Function image3 ($ length = 4, $ type = 'png ', $ width = 180, $ height = 60, $ fontface = 'fpnf. ttf', $ verifyName = 'verify '){
$ Code = $ this-> rand_string ($ length, 4 );
$ Width = ($ length * 25)> $ width? $ Length * 25: $ width;
$ AuthCode = new Zend_Session_Namespace ('auth _ Code ');
$ AuthCode-> imagecode = $ randval;
$ Im = imagecreatetruecolor ($ width, $ height );
$ BorderColor = imagecolorallocate ($ im, 100,100,100); // border color
$ Bkcolor = imagecolorallocate ($ im, 250,250,250 );
Imagefill ($ im, 0, 0, $ bkcolor );
@ Imagerectangle ($ im, 0, 0, $ width-1, $ height-1, $ borderColor );
// Interference
For ($ I = 0; $ I <15; $ I ++ ){
$ Fontcolor = imagecolorallocate ($ im, mt_rand (0,255), mt_rand (0,255), mt_rand (0,255 ));
Imagearc ($ im, mt_rand (-10, $ width), mt_rand (-10, $ height), mt_rand (30,300), mt_rand (20,200), 55,44, $ fontcolor );
}
For ($ I = 0; I I <255; $ I ++ ){
$ Fontcolor = imagecolorallocate ($ im, mt_rand (0,255), mt_rand (0,255), mt_rand (0,255 ));
Imagesetpixel ($ im, mt_rand (0, $ width), mt_rand (0, $ height), $ fontcolor );
}
If (! Is_file ($ fontface )){
$ Fontface = dirname (_ FILE _). "/". $ fontface;
}
For ($ I = 0; $ I <$ length; $ I ++ ){
$ Fontcolor = imagecolorallocate ($ im, mt_rand (0,120), mt_rand (0,120), mt_rand (0,120); // This ensures that the random color is darker.
$ Codex = substr ($ code, $ I, 1 );
Imagettftext ($ im, mt_rand (16, 20), mt_rand (-60, 60), 40 * $ I + 20, mt_rand (30, 35), $ fontcolor, $ fontface, $ codex );
}
$ This-> output ($ im, $ type );
}
Function output ($ im, $ type = 'png ')
{
Header ("Content-type: image/". $ type );
$ ImageFun = 'image'. $ type;
$ ImageFun ($ im );
Imagedestroy ($ im );
}