标签:== pos ace points 就删除 lin 级别 with nts
index.php
<?php
header(‘Content-type:text/html;charset=UTF-8‘);
// 指定允许其他域名访问
header(‘Access-Control-Allow-Origin:*‘);
// 响应类型f
header(‘Access-Control-Allow-Methods:POST‘);
// 响应头设置
header(‘Access-Control-Allow-Headers:x-requested-with,content-type‘);
include ‘phpqrcode.php‘;
//$uid = "100001";
$uid = $_POST["uid"];
$qrcodeurl = ‘qrcode‘.$uid.‘.png‘;
$code = $uid.".png";
//二维码内容
$url = "http://域名/tp3.2/home/Wx2/code?uid=".$uid;//二维码内容
//容错级别
$errorCorrectionLevel = ‘L‘;
//生成图片大小
$matrixPointSize = 4;
QRcode::png($url, $qrcodeurl, $errorCorrectionLevel, $matrixPointSize, 2);
//code【二维码+头像存放地址】、header【头像存放地址】、qrcode【二维码存放地址】
//准备好的logo图片,本人放在了根目录下
//头像地址[读数据库里面的头像具体到服务器的头像地址save_url]
//$logo = ‘http://域名/tp3.2/Public/upload/header/header2.png‘;
require_once(‘file1.php‘);
$logo = func1($uid);
//已经生成的原始二维码图,也在根目录下
$qrcode = $qrcodeurl;
//logo图片存在
if ($logo !== FALSE) {
$qrcode = imagecreatefromstring(file_get_contents($qrcode));
$logo = imagecreatefromstring(file_get_contents($logo));
if (imageistruecolor($logo))
{
imagetruecolortopalette($logo, false, 65535);//添加这行代码来解决颜色失真问题
}
$qrcode_width = imagesx($qrcode); //二维码图片宽度
$qrcode_height = imagesy($qrcode); //二维码图片高度
$logo_width = imagesx($logo); //logo图片宽度
$logo_height = imagesy($logo); //logo图片高度
$logo_qr_width = $qrcode_width / 5;
$scale = $logo_width / $logo_qr_width;
$logo_qr_height = $logo_height / $scale;
$from_width = ($qrcode_width - $logo_qr_width) / 2;
//重新组合图片并调整大小
imagecopyresampled($qrcode, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,
$logo_qr_height, $logo_width, $logo_height);
}
//输出图片
imagepng($qrcode, $code);//保存合成图片,命名logqr.png放在该地址中
imagedestroy($qrcode);
imagedestroy($logo);
if(file_exists($qrcodeurl)){ //存在二维码图片
unlink($qrcodeurl);
//echo ‘输出code3下面的图片为66存在二维码图片就删除222:‘.‘<img src="‘.$code.‘" >‘;
$showcode = "http://域名/code4/".$code;
$json = json_encode($showcode,JSON_UNESCAPED_UNICODE);
$json = str_replace("\\/","/",$json);//以免url地址被反编译
echo $json;
}
else { //不存在二维码图片
//echo ‘输出code3下面的图片为66不存在二维码图片就不管222:‘.‘<img src="‘.$code.‘" >‘;
$showcode = "http://域名/code4/".$code;
$json = json_encode($showcode,JSON_UNESCAPED_UNICODE);
$json = str_replace("\\/","/",$json);//以免url地址被反编译
echo $json;
}
//echo ‘输出的图片为66:‘.‘<img src="‘.$code.‘" >‘;
?>
file.php
<?php
function func1($uid)
{
$servername = ‘IP‘;
$username = ‘用户名‘;
$password = ‘密码‘;
$dbname = ‘数据库名称‘;
$port = ‘端口‘;
// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname,$port);
// Check connection
if ($conn->connect_error) {
die("连接失败: " . $conn->connect_error);
}
//$uid = "100001";
$sql = "SELECT header.save_url FROM header where uid=‘$uid‘";
$result = $conn->query($sql);
$arr = mysqli_fetch_row($result);
$save_url = $arr[0];
$conn->close();
return $save_url;
}
标签:== pos ace points 就删除 lin 级别 with nts
原文地址:https://www.cnblogs.com/xieqijiang/p/10768099.html