From 6e5de48858e40493f8e7a9c952d535646e64bee6 Mon Sep 17 00:00:00 2001 From: w01f Date: Sun, 15 Dec 2013 14:48:28 +0100 Subject: [PATCH] Update qrencode.php /* vv01f added for * easier (simple call) and * (old browser) compatible * no need to write files on servers inclusion of qr-codes in php generated html */ /* usage: * * Bitcoin QRCode * * *
'). * .QRCode::divHTML('text for qrcode') * .'
'; * ob_end_flush(); * ?> */ --- qrencode.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/qrencode.php b/qrencode.php index 277d3c1..2773043 100644 --- a/qrencode.php +++ b/qrencode.php @@ -292,7 +292,36 @@ public static function text($text, $outfile = false, $level = QR_ECLEVEL_L, $siz $enc = QRencode::factory($level, $size, $margin); return $enc->encode($text, $outfile); } - + +/* vv01f added for + * easier (simple call) and + * (old browser) compatible + * no need to write files on servers + inclusion of qr-codes in php generated html +*/ + public static function divHTML( + $text, + $tpl = array( /* changeable html markup */ + '1' => '
', + '0' => '
', + 'n' => '
' + ), + $level = QR_ECLEVEL_L + ) { + $enc = QRencode::factory($level); + $html = ''; + foreach ($enc->encode($text, false) as $l) { + for ($i = 0; $i < strlen($l); $i++) { + $html .= (($l[$i]=='1') + ? $tpl['1'] + : $tpl['0'] + ); + } + $html .= ($tpl['n']); + } + return $html; + } + //---------------------------------------------------------------------- public static function eps($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint=false, $back_color = 0xFFFFFF, $fore_color = 0x000000) {