Yzmcms 之api接口模块知识点

验证码生成函数:

public function code(){

$code = yzm_base::load_sys_class('code');//加载code验证码类

if(isset($_GET['width']) && intval($_GET['width'])) $code->width = intval($_GET['width']);//定义宽度

if(isset($_GET['height']) && intval($_GET['height'])) $code->height = intval($_GET['height']);//定义高度

if(isset($_GET['code_len']) && intval($_GET['code_len'])) $code->code_len = intval($_GET['code_len']);//定义验证码长度,也就是几位数的验证码

if(isset($_GET['font_size']) && intval($_GET['font_size'])) $code->font_size = intval($_GET['font_size']);//定义字体大小

if($code->width > 500 || $code->width < 10)  $code->width = 100;//如果定义的宽度没在10-500之间,直接固定100

if($code->height > 300 || $code->height < 10)  $code->height = 35;//如果定义的高度没在10-300之间,直接固定35

if($code->code_len > 8 || $code->code_len < 2)  $code->code_len = 4;//如果验证码长度没在2-8位,直接固定4位

$code->show_code();//展示验证码

$_SESSION['code'] = $code->get_code();//得出的验证码存session

}

D($dbname)->field('id')->where(array('title'=>$title))->one();获取单条结果的一个字段

$userid = $this->_check_login(); 检查是否登录

$total = D('message_group')->alias('a')->join('yzmcms_message_data b ON a.id=b.group_message_id', 'LEFT')->where(array('a.groupid'=>$memberinfo['groupid'], 'a.status'=>1, 'b.userid'=>$userid))->total();连表查询


get_model($modelid)//根据modelid获取数据表

D('favorite')->insert($data);添加数据




联系我们

在线咨询:点击这里给我发消息

邮件:w420220301@qq.com