QrCode.php 960 字节
Newer Older
G
gongfuxiang 已提交
1
<?php
D
qrcode  
devil_gong 已提交
2
namespace app\index\controller;
G
gongfuxiang 已提交
3 4 5 6 7 8 9 10

/**
 * 二维码生成控制层
 * @author   Devil
 * @blog     http://gong.gg/
 * @version  0.0.1
 * @datetime 2016-12-01T21:51:08+0800
 */
D
qrcode  
devil_gong 已提交
11
class QrCode extends Common
G
gongfuxiang 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25
{
    /**
     * [__construct 构造方法]
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * [Index 首页方法]
     */
    public function Index()
    {
D
qrcode  
devil_gong 已提交
26
        require_once ROOT.'extend'.DS.'qrcode'.DS.'phpqrcode.php';
G
gongfuxiang 已提交
27 28 29 30 31 32 33 34 35
        
        $level = isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L','M','Q','H')) ? $_REQUEST['level'] : 'L';
        $point_size = isset($_REQUEST['size']) ? min(max(intval($_REQUEST['size']), 1), 10) : 6;
        $mr = isset($_REQUEST['mr']) ? intval($_REQUEST['mr']) : 1;
        $content = isset($_REQUEST['content']) ? urldecode(trim($_REQUEST['content'])) : __MY_URL__;
        \QRcode::png($content, false, $level, $point_size, $mr);
    }
}
?>