<?php /** * Created by PhpStorm. * User: xmy 280564871@qq.com * Date: 2017/4/18 * Time: 15:22 */ namespace Open\Controller; use Think\Controller; class BaseController extends Controller{ public function _initialize(){ /* 读取数据库中的配置 */ $config = S('DB_CONFIG_DATA'); if(!$config){ $config = api('Config/lists'); S('DB_CONFIG_DATA',$config); } C($config); //添加配置 } /** * 验证码显示 * author: xmy 280564871@qq.com */ public function verify($id){ $config = array( 'seKey' => 'ThinkPHP.CN', //验证码加密密钥 'fontSize' => 22, // 验证码字体大小(px) 'imageH' => 50, // 验证码图片高度 'imageW' => 180, // 验证码图片宽度 'length' => 4, // 验证码位数 'fontttf' => '4.ttf', // 验证码字体,不设置随机获取 ); ob_clean(); $verify = new \Think\Verify($config); $verify->codeSet = '0123456789'; $verify->entry($id); } /** * 页码显示 * @param $count * @param int $row * author: xmy 280564871@qq.com */ public function showPage($count,$row=10){ if($count > $row){ $page = new \Think\Page($count, $row); $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%'); $this->assign('_page', $page->show()); } } }