20,359
社区成员
发帖
与我相关
我的任务
分享
//读缓存
function read_qrcode_cache($filename)
{
$result = array();
if (!empty($result[$filename])) {
return $result[$filename];
}
$filepath = PHPMPS_ROOT . 'data/qrcodecache/' . $filename;
if (file_exists($filepath)) {
include_once($filepath);
$result[$filename] = $data;
return $result[$filename];
} else {
return false;
}
}
//写入缓存
function write_qrcode_cache($filename, $val)
{
$errorCorrectionLevel = 'L';//容错级别
$matrixPointSize = 4;//生成图片大小
$filepath = PHPMPS_ROOT . 'data/qrcodecache/' . $filename;
QRcode::png($val, $filepath, $errorCorrectionLevel, $matrixPointSize, 0);
}
//调用缓存函数的代码
$value = 'BEGIN:VCARDVERSION:3.0N:' . $info['title'] . 'TEL:0575-87238712TEL;CELL:18969558900ORG:' . $info['title'] . 'END:VCARD';
$filename = md5($value).'.png';
$data = read_qrcode_cache($filename);
if ($data === false) {
write_qrcode_cache($filename,$value);
}
$info['Qrcode'] = $CFG['weburl'] . '/data/qrcodecache/' . $filename;