|
效果图:
密保卡入库
[U]复制代码[/U] 代码如下:
$this->load->model('admin/m_mibao');
$data = array();
//生成随机横坐标
$rand_str = $this->_rand_str(10);
$arr = array();
for($k=0;$k_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);
密保卡图片生成
[U]复制代码[/U] 代码如下:
//就是算坐标
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);
$fontcolor = imagecolorallocate($im, 0, 0, 0);
$top_rectangle_color = imagecolorallocate($im,241,254,237);
$top_letter_color = imagecolorallocate($im,54,126,76);
$left_rectangle_color = imagecolorallocate($im,243,247,255);
$left_num_color = imagecolorallocate($im,4,68,192);
$logo_str_color = imagecolorallocate($im,0,0,0);
imagefill($im,0,0,imagecolorallocate($im,255,255,255)); //图片背景色
$font = './public/baomi/fonts/simsun.ttc'; //字体
$font_en = './public/baomi/fonts/CONSOLA.TTF'; //英文字体
$font2 = './public/baomi/fonts/simhei.ttf'; //密保卡上方黑体
$dst = imagecreatefromjpeg("./public/baomi/120.jpg");
imagecopymerge($im,$dst,120,15,0,0,193,55,100);
imageline($im,10,72,$width-10,72,$linecolor);
$ltext = "电子密保卡";
if(!imagettftext($im,10,0,340,47,$logo_str_color,$font2,$ltext)) {
exit('error');
}
//写入卡号
$b = '1000' . $info['card_num'];
for($i=0;$i
密保卡验证
[U]复制代码[/U] 代码如下:
public function test1($uid)
{
$this->load->model('admin/m_users');
$user = $this->m_users->sel($uid);
//post提交过来验证
if($this->is_post())
{
$codes = $this->m_mibao->get_codes_by_uid($uid);
$codes = unserialize($codes);
$is_true = true;
foreach($_SESSION['mibao']['keys'] as $key)
{
if($codes[$key] != $_POST['values'][$key])
{
$is_true = false;
}
}
if($is_true)
{
die('正确');
}
else
{
die('错误');
}
}
else
{
//渲染视图
$info = $this->m_mibao->get_by_uid($uid);
$data = array();
$data['keys'] = $this->m_mibao->get_rand_keys($info['letter']);
$_SESSION['mibao']['keys'] = $data['keys'];
$data['uid'] = $uid;
$this->load->view('test1',$data);
}
脚本之家打包下载
您可能感兴趣的文章:PHP文件下载类实现php加速的eAccelerator dll支持文件打包下载PHP简单系统查询模块代码打包下载PHPWind 发帖回帖Api PHP版打包下载php 仿Comsenz安装效果代码打包提供下载使用ThinkPHP自带的Http类下载远程图片到本地的实现代码Php中文件下载功能实现超详细流程分析php文件打包 下载之使用PHP自带的ZipArchive压缩文件并下载打包好的文件php在程序中将网页生成word文档并提供下载的代码解决PHP超大文件下载,断点续传下载的方法详解php 下载保存文件保存到本地的两种实现方法ThinkPHP实现将本地文件打包成zip下载PHP实现远程下载文件到本地PHP在线打包下载功能示例
|
|