Welcome to the Linux community forum and interact with 2 million technical staff to enter the header (Content-type: imagejpeg); $ codeimagejpeg ($ this-im);} elseif (function_exists (imagegif )) {header (Content-type: imagegif); $ codeimagegif ($ this-im);} imagedestroy ($ this
Welcome to the Linux community forum and interact with 2 million technical staff> enter header ("Content-type: image/jpeg"); $ code = imagejpeg ($ this-im );} elseif (function_exists ("imagegif") {header ("Content-type: image/gif"); $ code = imagegif ($ this-im);} imagedestroy ($ this
Welcome to the Linux community forum and interact with 2 million technicians>
Header ("Content-type: image/jpeg ");
$ Code = imagejpeg ($ this-> im );
} Elseif (function_exists ("imagegif "))
{
Header ("Content-type: image/gif ");
$ Code = imagegif ($ this-> im );
}
Imagedestroy ($ this-> im );
Return $ code;
}
/**
* Check the verification code
* @ Param $ code
* @ Return bool
*/
Public function checkCode ($ code ){
Session_start ();
$ Secode = explode (',', $ _ SESSION ['initphp _ Code']);
$ Time = time ();
// Check whether the time has expired
If ($ secode [0]> $ time | $ time-$ secode [0]> $ this-> time)
{
Return false;
}
// Whether the verification code is consistent after the two-md5 key pairs
If ($ secode [1] <> md5 (md5 ($ code. 'initphzmsy'. $ secode [0]) {
Return false;
}
// Check whether the verification code string is consistent
If ($ code | $ code <> $ secode [2])
{
Return false;
}
Return true;
}
/* Random Twist */
Public function setWarping (){
$ Rgb = array ();
$ Direct = rand (0, 1 );
$ Width = imagesx ($ this-> im );
$ Height = imagesy ($ this-> im );
$ Level = $ width/20;
For ($ j = 0; $ j <$ height; $ j ++ ){
For ($ I = 0; $ I <$ width; $ I ++ ){
$ Rgb [$ I] = imagecolorat ($ this-> im, $ I, $ j );
}
For ($ I = 0; $ I <$ width; $ I ++ ){
$ R = sin ($ j/$ height * 2 * M_PI-M_PI * 0.5) * ($ direct? $ Level:-$ level );
Imagesetpixel ($ this-> im, $ I + $ r, $ j, $ rgb [$ I]);
}
}
}
}
?>
Effect:
[1] [2]