コード例 #1
0
ファイル: QRencode.php プロジェクト: sss201413/ecstore
 public function encode($intext, $outfile = false)
 {
     $code = new weixin_qrcode_QRcode();
     if ($this->eightbit) {
         $code->encodeString8bit($intext, $this->version, $this->level);
     } else {
         $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
     }
     weixin_qrcode_QRtools::markTime('after_encode');
     if ($outfile !== false) {
         file_put_contents($outfile, join("\n", weixin_qrcode_QRtools::binarize($code->data)));
     } else {
         return weixin_qrcode_QRtools::binarize($code->data);
     }
 }
コード例 #2
0
ファイル: qrcode.php プロジェクト: noikiy/Ecstore-to-odoo
 /**
  * 根据需要生成二维码的数据(URL),生成二维码,并保存到storager
  *
  * $params string $data  可以是URL,文字
  */
 public function store($data, $matrixPointSize = null, $errorCorrectionLevel = null)
 {
     $matrixPointSize = $matrixPointSize ? $matrixPointSize : $this->matrixPointSize;
     $errorCorrectionLevel = $errorCorrectionLevel ? $errorCorrectionLevel : $this->errorCorrectionLevel;
     $imageModel = app::get('image')->model('image');
     $image_id = $this->gen_qrcode_image_id($data, $matrixPointSize, $errorCorrectionLevel);
     if (!$imageModel->getRow('image_id', array('image_id' => $image_id))) {
         $filename = tempnam($this->tmp_dir, 'qrcode');
         weixin_qrcode_QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
         list($w, $h) = getimagesize($filename);
         $storager = new base_storager();
         list($url, $ident, $storage) = explode("|", $storager->save_upload($filename, 'image', '', $msg, $this->extname));
         $params = array('image_id' => $image_id, 'storage' => $storage, 'image_name' => '二维码图片', 'ident' => $ident, 'url' => $url, 'width' => $w, 'height' => $h, 'last_modified' => time());
         $imageModel->save($params);
         unlink($filename);
     }
     return $image_id;
 }
コード例 #3
0
ファイル: QRtools.php プロジェクト: sss201413/ecstore
 public static function tcpdfBarcodeArray($code, $mode = 'QR,L', $tcPdfVersion = '4.5.037')
 {
     $barcode_array = array();
     if (!is_array($mode)) {
         $mode = explode(',', $mode);
     }
     $eccLevel = 'L';
     if (count($mode) > 1) {
         $eccLevel = $mode[1];
     }
     $qrTab = weixin_qrcode_QRcode::text($code, false, $eccLevel);
     $size = count($qrTab);
     $barcode_array['num_rows'] = $size;
     $barcode_array['num_cols'] = $size;
     $barcode_array['bcode'] = array();
     foreach ($qrTab as $line) {
         $arrAdd = array();
         foreach (str_split($line) as $char) {
             $arrAdd[] = $char == '1' ? 1 : 0;
         }
         $barcode_array['bcode'][] = $arrAdd;
     }
     return $barcode_array;
 }