I have read discuz. I don't like it. It's too troublesome for pictures and fonts.
The method I use does not require additional images, fonts, or php support libraries, because my method is to directly use php functions such as ord and chr to operate the image source code.
Images are composed of binary code, such as bmp, png, jpg, and gif. Since php can generate gif images that are not movable, why can't we generate animated gif images? The difference is nothing more than binary code. There is no difference in the Process of generation. So I wrote this class based on this idea to generate a movable verification code.
Of course, the most fundamental reason is that the traditional verification code can be recognized by others using programs. some non-traditional ones like me may have animated verification codes to be recognized by them. If a master can recognize the verification codes, please leave a message here to tell me.
// If you want to publish this article, please indicate the exit, no outgoing copyright notice, I do not like to see this kind of website. My work website does not indicate the person who is serving Seven {See7di # Gmail.com}
The following is a demo:
The source code is first sent out, because many copy companies directly copy and paste my stuff without even saying goodbye, or even leave me some copyright information, so if you need the complete source code, you can e-mail me for (see7di@gmail.com)
// If you want to publish this article, please indicate the exit, no outgoing copyright notice, I do not like to see this kind of website. My work website does not indicate the person who is serving Seven {See7di # Gmail.com}
<? PHP
// [Can be animated image verification code!] (C) 2011 Seven (See7di@Gmail.com ).
// This is a freeware and you can copy it to anyone, But please don't del this message, Thank you!
// Seven (See7di@Gmail.com) http://hi.baidu.com/see7di/home
Class ClassGif {
Var $ Pic = Array ();
Var $ TOP = "GIF89a ";
Var $ LOP = 0; // Is loop [0, 1]
Var $ FLY = 20; // animation speed [0->]
Var $ DIS = 2; // [0, 1, 2, 3]
Var $ RGB =-1;
Var $ IMG =-1;
// Gif encoding. (height, width, bgcolor)
Function ClassGif ($ Gh, $ Gw, $ Co ){
$ Gh = (! $ Gh )? 18: $ Gh; $ Gw = (! $ Gw )? 60: $ Gw;
IF (! $ Co) {$ Co = '2017 | 255 | 100';} $ Co = Explode ("|", $ Co );
$ _ T = StrtoUpper (Dechex (Mt_Rand (). Dechex (Mt_Rand (). Dechex (Mt_Rand )));
$ _ SESSION ['cod '] = StrToLower ($ _ T );
$ Img = Array ();
For ($ I = 0; $ I <$ Gh; $ I ++ ){
$ Image = Imagecreate ($ Gw, $ Gh );
Imagecolorallocate ($ Image, $ Co [0], $ Co [1], $ Co [2]);
$ _ L1 = Imagecolorallocate ($ Image, Rand (150,255), Rand (200,255), Rand (200,255 ));
$ _ L2 = Imagecolorallocate ($ Image, Rand (1,200), Rand (1,200), Rand (1,200 ));
Imagestring ($ Image, 5, Rand (-4, ($ Gw/2), Rand (-3, 5), Rand (random, 20000), $ _ L1); // interference
Imagestring ($ Image, 7, Rand (0, ($ Gw/2), Rand (-3, 5), $ _ T, $ _ L2); // content
ImageGif ($ Image); Imagedestroy ($ Image );
$ Img [] = ob_get_contents (); OB_clean ();
}
$ This-> _ Gif ($ Img );
}
// Entity. (Img array)
Function _ Gif ($ _ Src ){
$ This-> RGB = ($ this-> RGB>-1 )? ($ This-> RGB | ($ this-> RGB <8) | ($ this-> RGB <16):-1;
For ($ I = 0; $ I <Count ($ _ Src); $ I ++ ){
$ This-> Pic [] =$ _ Src [$ I];
For ($ j = (13 + 3*(2 <(Ord ($ this-> Pic [$ I] {10}) & 0x07 ))), $ k = True; $ k; $ j ++ ){
Switch ($ this-> Pic [$ I] {$ j }){
Case "! ":
IF (SubStr ($ this-> Pic [$ I], ($ j + 3), 8) = "NETSCAPE "){
Echo 'error: Can \'t use src [', ($ I + 1),'] to create image! ';
Exit (0 );
}
Break;
Case ";":
$ K = False;
Break;
}
}
}
$ This-> _ Header ();
For ($ I = 0; $ I <Count ($ this-> Pic); $ I ++ ){
$ This-> _ Frame ($ I, $ this-> FLY );
}
$ This-> _ Footer ();
$ This-> _ Animation ();
}
The code will not be sent, so it will be requested by someone who really needs it ..