密保卡入库
- $this->load->model(''admin/m_mibao'');
-
- $data = array();
- //生成随机横坐标
- $rand_str = $this->_rand_str(10);
-
- $arr = array();
- for($k=0;$k<strlen($rand_str);$k++)
- {
- for ($i = 1;$i < 9;$i++)
- {
- $rand = $this->_rand_num(3);
- //赋给所有code的容器
- $arr[$rand_str{$k} . $i] = $rand;
- }
- }
-
- $data[''code''] = serialize($arr); //序列化后将信息入库
- $data[''letter''] = $rand_str;
-
- //避免重复序列号
- while (TRUE)
- {
- $data[''card_num''] = $this->_rand_num(20);
- //判断序列号是否重复存在
- if($this->m_mibao->has_card_num($data[''card_num'']) == 0)
- {
- break;
- }
- }
-
- $data[''add_time''] = TIME;
- $data[''user_id''] = $uid;
-
- echo $this->mibao->insert($data);
密保卡图片生成
- //就是算坐标
- public function show($user_id)
- {
- $this->load->model(''admin/m_mibao'');
- $info = $this->m_mibao->get_by_uid($user_id);
- if(emptyempty($info))
- {
- $this->msg(''该用户无密保卡!'',''admin-index'');
- }
-
- $codes = unserialize($info[''code'']);
-
- //图片初始值
-
- $bit = 3; //密保卡位数
-
- $height = 332; //图片高度
-
- $width = 626; //图片宽度
-
- $im = imagecreatetruecolor($width,$height);
-
- $linecolor = imagecolorallocate($im, 229,229,229);
-
- $fo
|