/**
*
in ThinkPHP
* Just let other Actions inherit the current CommonAction
*/
class CommonAction extends Action{
public function verify(){
//Import verification code class
//Method 1:
import('ORG.Util.Image');
//Method 2: @ represents the lib folder of the current project (you need to copy it yourself or write a new class yourself)
// import('@.ORG.Image')
// Image::buildImageVerify();
//Extended modifications
/**
* @param string $length digits
* @param string $mode Type (0 letters, 1 number, 2 uppercase letters, 3 lowercase letters, 4 Chinese, 5 mixed)
* @param string $type image format
* @param string $width width
* @param string $height 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 will have a problem: msubstr has an error)
//1. Modify function::msubstr
//2. Adding font ttf needs to be placed under the same level directory as image
//Extensions can be viewed in the class file
// 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 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 theme style (see documentation)
// $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("验证码错误");
}
}
function next(){
}
}
?>
index
[php]
ID
用户名
IP
http://www.bkjia.com/PHPjc/477786.html www.bkjia.com true http://www.bkjia.com/PHPjc/477786.html TechArticle CommonAction [php] ?php /*** In ThinkPHP * Just let other Actions inherit the current CommonAction.*/ class CommonAction extends Action{ public function verify(){ //导入验证...
Statement: The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn