예제 #1
0
function plugin_qrcode_action()
{
    global $vars;
    if (empty($vars['d'])) {
        // 透過PNG
        $buffer = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQI12NgYAAAAAMAASDVlMcAAAAASUVORK5CYII=');
    } else {
        $qr = new PHPQRCode\QRcode();
        // 宣言
        $qr->version = empty($vars['v']) ? 0 : $vars['v'];
        // バージョン
        $qr->mask = empty($vars['m']) ? PHPQRCode\Constants::QR_DEFAULT_MASK : $vars['m'];
        // 分割数
        $qr->count = empty($vars['n']) ? 1 : $vars['n'];
        //
        $qr->hint = empty($vars['h']) ? PHPQRCode\Constants::QR_MODE_AN : $vars['h'];
        // 文字コード
        //	$parity = (empty($vars['p'])) ? 0	: $vars['p'];	// パリティ(使用しない)
        $buffer = $qr->png(rawurldecode($vars['d']), false, empty($vars['e']) ? 'M' : $vars['e'], empty($vars['s']) ? 1 : $vars['s'], 2);
    }
    // 出力
    Header::writeResponse(Header::getHeaders('image/png'), 200, $buffer);
    exit;
}
예제 #2
0
 /**
  * Generates a QR code for the certificate. The QR code embeds the text given
  * @param    string    $text Text to be added in the QR code
  * @param    string    $path file path of the image
  * */
 public function generate_qr($text, $path)
 {
     //Make sure HTML certificate is generated
     if (!empty($text) && !empty($path)) {
         //L low, M - Medium, L large error correction
         return PHPQRCode\QRcode::png($text, $path, 'M', 2, 2);
     }
     return false;
 }