ThinkPHP study notes ThinkPHP paging and verification code usage. CommonAction [php]? * In php *** ThinkPHP, * allow other actions to inherit the current CommonAction. * classCommonActionextendsAction {publicfunctionverify () {import verification CommonAction
[Php]
/**
* In ThinkPHP
* Let other actions inherit the current CommonAction.
*/
Class CommonAction extends Action {
Public function verify (){
// Import verification code
// Method 1:
Import ('org. Util. image ');
// Method 2: @ represents the lib folder of the current project (you need to copy or write a new class yourself)
// Import ('@. ORG. image ')
// Image: buildImageVerify ();
// Extended modification
/**
* @ Param string $ length digits
* @ Param string $ mode type (0 letters, 1 digit, 2 uppercase letters, 3 lowercase letters, 4 Chinese characters, 5 mixed)
* @ Param string $ type Image format
* @ Param string $ width
* @ Param string $ height
* BuildImageVerify ($ length = 4, $ mode = 1, $ type = 'PNG ', $ width = 48, $ height = 22, $ verifyName = 'verify ')
*/
Image: buildImageVerify (5, 5, 'PNG ', 80, 22 );
// Chinese verification code (2.0 has a problem: msubstr has an error)
// 1. modify function: msubstr
// 2. add the ttf font to the directory at the same level as the image.
// Extensions can be viewed in class files
// Image: GBVerify ();
}
}
?>
PageAction
[Php]
/**
* In ThinkPHP
*/
Class PageAction extends CommonAction {
Public function index (){
// Import page
Import ('org. Util. page ');
$ User = M ('user ');
$ Count = $ user-> count ();
$ Page = new Page ($ count, 3 );
// Modify the prompt information
$ Page-> setConfig ('header', "member ");
$ Page-> setConfig ('prev', "previous Group ");
$ Page-> setConfig ('next', "next Group ");
$ Page-> setConfig ('first', "homepage ");
$ Page-> setConfig ('last', "last page ");
// Define the theme style (see the document)
// $ Page-> setConfig ('theme ','
%
');
$ Show = $ page-> show ();
$ List = $ user-> order ('Id desc')-> limit ($ page-> firstRow. ','. $ page-> listRows)-> select ();
$ This-> assign ('title', 'Page Demo ');
$ This-> assign ('alist', $ list );
$ This-> assign ('page', $ show );
$ This-> display ();
}
Function check (){
$ Verify = $ _ SESSION ['verify '];
If ($ verify! = Md5 ($ _ POST ['verify ']) {
$ This-> error ("verification code error ");
}
}
Function next (){
}
}
?>
Index
[Php]
ID
User name
IP