Verification code: import the verification code class in aoli \ ThinkPHP \ Lib \ ORG \ Util \ Image. class. php: buildImageVerify ($ length, $ mode, $ type...
Verification code:Import the verification code class. there is a verification code method in aoli \ ThinkPHP \ Lib \ ORG \ Util \ Image. class. php.
Verification code: buildImageVerify ($ length, $ mode, $ type, $ width, $ height, $ verifyName)
Length: the length of the verification code. the default value is 4 digits.
Mode: verify the string type. the default value is a number. other supported types include 0 letters, 1 digits, 2 uppercase letters, 3 lowercase letters, and 4.
Mix Chinese 5 (remove confusing characters oOLl and number 01)
Type: the image type of the verification code. the default value is png.
Width: the verification code width. it is automatically calculated based on the verification code length by default.
Height: the height of the verification code. the default value is 22.
VerifyName: The SESSION record name of the verification code. the default value is verify.
Chinese verification code: GBVerify ($ length, $ type, $ width, $ height, $ fontface, $ verifyName)
Length: the length of the verification code. the default value is 4 digits.
Type: the image type of the verification code. the default value is png.
Width: the verification code width. it is automatically calculated based on the verification code length by default.
Height: height of the verification code. the default value is 50.
Fontface: the font file used. use the complete file name or put it under the Directory where the image class is located. the default font file used is simhei. ttf (this file can be found in the Fonts directory of the window)
VerifyName: The SESSION record name of the verification code. the default value is verify.
If the verification code cannot be displayed, check:
Whether the GD library support has been installed in PHP;
Whether there is any output before the output (especially the output of the BOM header of UTF8 );
Whether the Image Class Library is correctly imported;
If the Chinese verification code is used, check whether the font file is copied to the directory where the class library is located;
CommonAction. class. php
- Class CommonAction extends Action {
- Function verify (){
- Import ('org. Util. image ');
- // English verification code
- // Image: buildImageVerify (5, 5, gif, 90,30, 'verify ');
- // Chinese verification code
- Image: GBVerify ();
- }
- }
- ?>
Template index.html
- Verification code:
-
-
- Function show (obj ){
- Obj. src = "_ APP _/common/verify/random/" + Math. random ();
- }
-
Controller UserAction. class. php
- // Verification code
- If ($ _ SESSION ['verify ']! = Md5 ($ _ POST ['verify ']) {
- $ This-> error ('incorrect verification code ');
- }
Paging:// Import the paging class. the verification code method is available in aoli \ ThinkPHP \ Lib \ ORG \ Util \ Page. class. php.
UserAction. class. php
- Function index (){
- Import ('org. Util. page'); // introduce the distribution class
- $ User = M ('user ');
- $ Count = $ user-> count ();
- $ Page = new Page ($ count, 3); // 5 entries per page
- $ Page-> setConfig ('theme ',' total: % totalRow % header % nowPage %/% totalPage % Page % first % upPage % prePage % linkPage % nextPage % downPage % end % ');
- $ Show = $ page-> show ();
- $ List = $ user-> field (array ('id', 'username', 'createip')-> order ('Id desc ') -> limit ($ page-> firstRow. ','. $ page-> listRows)-> select ();
- $ This-> assign ('alist', $ list );
- $ This-> assign ('page', $ show );
- $ This-> display ();
- }
Template page index.html
- ID:{$ Vo ['id']}User name:{$ Vo ['username']}Registered ip address:{$ Vo ['createip']} Delete Edit
-
- {$ Page}