123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- namespace app\admin\controller;
- use think\Controller;
- class Qrcode extends Controller
- {
- public function qrcode(){ // 流程超时提醒
- $yqcode = input('code','','trim');
- $type = input('type/d',0); // 0=不做处理 1=think
- if($type == 1){
- $yqcode = think_decrypt($yqcode);
- }
- //生成二维码图片
- $object = new \phpqrcode\QRcode();
- $level=3;
- $size=9;
- $errorCorrectionLevel =intval($level) ;//容错级别
- $matrixPointSize = intval($size);//生成图片大小
- $temp = './uploads/temp/'.md5($yqcode).'.png';
- $temp2 = './uploads/temp/'.md5($yqcode).'_2.png';
- $templogo = './uploads/temp/'.md5($yqcode).'_logo.png';
- $object->png($yqcode, $temp, $errorCorrectionLevel, $matrixPointSize, 2);
- $image = \think\Image::open($temp);
- //
- $logowidth = round($image->width()/4);
- //
- $orgId = cur_org_id();
- // if($orgId == 17){
- // $logo = './hb.png';
- // }else{
- // $logo = './logo.png';
- // }
- $logo = './logo.png';
- $imagelogo = \think\Image::open($logo);
- $imagelogo->thumb($logowidth,$logowidth,\think\Image::THUMB_SCALING)->save($templogo);
- $image->water($templogo,\think\Image::WATER_CENTER)->save($temp2);
- $QRBuffer = imagecreatefromstring(file_get_contents($temp2));
- @unlink($temp);
- @unlink($temp2);
- @unlink($templogo);
- //输出图片
- ob_clean();
- header('Content-type: image/png');
- imagepng($QRBuffer);
- exit();
- }
- public function wj_code(){ //问卷调查
- $get = $_GET;
- $r = '';
- $i = 1;
- foreach ($get as $k=>$v){
- if(count($get)!=$i && $k!='url'){
- $r.=$k.'='.$v.'&';
- }else{
- if($k!='url'){
- $r.=$k.'='.$v;
- }else{
- if(count($get)==$i){
- $r.=$v;
- }else{
- $r.=$v.'&';
- }
- }
- }
- $i++;
- }
- // $value = $_GET['url'];//二维码内容
- $yqcode =$r;//二维码内容
- if (empty($yqcode)) {
- $this->error('URL不能为空');
- }
- //生成二维码图片
- $object = new \phpqrcode\QRcode();
- $level=3;
- $size=9;
- $errorCorrectionLevel =intval($level) ;//容错级别
- $matrixPointSize = intval($size);//生成图片大小
- $temp = './uploads/temp/'.md5($yqcode).'.png';
- $temp2 = './uploads/temp/'.md5($yqcode).'_2.png';
- $templogo = './uploads/temp/'.md5($yqcode).'_logo.png';
- $object->png($yqcode, $temp, $errorCorrectionLevel, $matrixPointSize, 2);
- $image = \think\Image::open($temp);
- //
- $logowidth = round($image->width()/4);
- //
- $orgId = cur_org_id();
- // if($orgId == 17){
- // $logo = './hb.png';
- // }else{
- // $logo = './logo.png';
- // }
- $logo = './logo.png';
- $imagelogo = \think\Image::open($logo);
- $imagelogo->thumb($logowidth,$logowidth,\think\Image::THUMB_SCALING)->save($templogo);
- $image->water($templogo,\think\Image::WATER_CENTER)->save($temp2);
- $QRBuffer = imagecreatefromstring(file_get_contents($temp2));
- @unlink($temp);
- @unlink($temp2);
- @unlink($templogo);
- //输出图片
- ob_clean();
- header('Content-type: image/png');
- imagepng($QRBuffer);
- exit();
- }
- }
|