添加后台代理代码
This commit is contained in:
59
codes/agent/game/api/sample/qrpay/index.php
Normal file
59
codes/agent/game/api/sample/qrpay/index.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
require_once './phpqrcode/merged/phpqrcode.php';
|
||||
|
||||
/**
|
||||
* @note 获取当前页面的完整连接
|
||||
* @return string
|
||||
*/
|
||||
function getLocaleUrl()
|
||||
{
|
||||
$is_https =
|
||||
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ||
|
||||
(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
|
||||
(isset($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] == 'https');
|
||||
|
||||
$request_scheme = $is_https ? 'https://' : 'http://';
|
||||
$hostname = $_SERVER['SERVER_NAME'];
|
||||
$hostport = (($is_https && '443' == $_SERVER['SERVER_PORT']) || (!$is_https && '80' == $_SERVER['SERVER_PORT'])) ? '' : ':' . intval($_SERVER['SERVER_PORT']);
|
||||
|
||||
return $request_scheme . $hostname . $hostport . $_SERVER['PHP_SELF'];
|
||||
}
|
||||
|
||||
/// 要生成二维码的地址
|
||||
$url = dirname(dirname(getLocaleUrl())) . '/onlinepay/index.php';
|
||||
|
||||
$local_path = dirname(__FILE__);
|
||||
$short_name = '/qrcodeimg/' . date('YmdHis') . '.png';
|
||||
$logo_name = $local_path . '/logo.png';
|
||||
$long_name = $local_path . $short_name;
|
||||
QRcode::png($url, $long_name, QR_ECLEVEL_L, 8, 2);
|
||||
|
||||
/// 合并二维码和logo图片
|
||||
$img = imagecreatefromstring(file_get_contents($long_name));
|
||||
$logo = imagecreatefromstring(file_get_contents($logo_name));
|
||||
if ($img && $logo)
|
||||
{
|
||||
$img_width = imagesx($img); /// 二维码图片宽度
|
||||
$img_height = imagesy($img); /// 二维码图片高度
|
||||
$logo_width = imagesx($logo); /// logo图片宽度
|
||||
$logo_height = imagesy($logo); /// logo图片高度
|
||||
$logo_qr_width = $img_width / 6;
|
||||
$scale = $logo_width / $logo_qr_width;
|
||||
$logo_qr_height = $logo_height / $scale;
|
||||
$from_width = ($img_width - $logo_qr_width) / 2;
|
||||
|
||||
/// 重新组合图片并调整大小
|
||||
imagecopyresampled($img, $logo, $from_width, $from_width, 0, 0, $logo_qr_width, $logo_qr_height, $logo_width, $logo_height);
|
||||
|
||||
/// 输出图片
|
||||
header('Content-type: image/png');
|
||||
imagepng($img);
|
||||
|
||||
imagedestroy($logo);
|
||||
imagedestroy($img);
|
||||
}
|
||||
|
||||
///$img_link = dirname(getLocaleUrl()) . $short_name;
|
||||
///echo "<center><a href=\"{$img_link}\"><img src=\"{$img_link}\"></a><br /><font size=\"20\">在线支付</font></center>";
|
||||
unlink($long_name);
|
||||
|
||||
Reference in New Issue
Block a user