From 6fe3fb9e23e622ddb69205172827a97120167574 Mon Sep 17 00:00:00 2001
From: PeratX <1215714524@qq.com>
Date: Fri, 10 Mar 2017 11:36:50 +0800
Subject: [PATCH] QRCode generate fix
---
src/PeratX/SFQRCode/QRCode.php | 8 ----
src/PeratX/SFQRCode/QREncode.php | 3 +-
src/PeratX/SFQRCode/QRSpec.php | 75 +-------------------------------
src/PeratX/SFQRCode/SFQRCode.php | 1 +
4 files changed, 3 insertions(+), 84 deletions(-)
diff --git a/src/PeratX/SFQRCode/QRCode.php b/src/PeratX/SFQRCode/QRCode.php
index e5c94fa..8110996 100644
--- a/src/PeratX/SFQRCode/QRCode.php
+++ b/src/PeratX/SFQRCode/QRCode.php
@@ -35,9 +35,6 @@ public function encodeMask(QRInput $input, $mask){
$frame = QRSpec::newFrame($version);
$filler = new FrameFiller($width, $frame);
- if(is_null($filler)){
- return NULL;
- }
// inteleaved data and ecc codes
for($i = 0; $i < $raw->dataLength + $raw->eccLength; $i++){
@@ -76,10 +73,6 @@ public function encodeMask(QRInput $input, $mask){
$masked = $maskObj->makeMask($width, $frame, $mask, $input->getErrorCorrectionLevel());
}
- if($masked == NULL){
- return NULL;
- }
-
$this->version = $version;
$this->width = $width;
$this->data = $masked;
@@ -116,7 +109,6 @@ public function encodeString($string, $version, $level, $hint, $casesensitive){
}
$input = new QRInput($version, $level);
- if($input == NULL) return NULL;
$ret = QRSplit::splitStringToQRInput($string, $input, $hint, $casesensitive);
if($ret < 0){
diff --git a/src/PeratX/SFQRCode/QREncode.php b/src/PeratX/SFQRCode/QREncode.php
index b6b2ae9..f9533f6 100644
--- a/src/PeratX/SFQRCode/QREncode.php
+++ b/src/PeratX/SFQRCode/QREncode.php
@@ -19,7 +19,7 @@
class QREncode{
public $caseSensitive = true;
- public $eightBit = false;
+ public $eightBit = true;
public $version = 0;
public $size = 3;
@@ -87,7 +87,6 @@ public function encode($intext){
$code->encodeString($intext, $this->version, $this->level, $this->hint, $this->caseSensitive);
}
- var_dump($code->data);
return QRTools::binarize($code->data);
}
diff --git a/src/PeratX/SFQRCode/QRSpec.php b/src/PeratX/SFQRCode/QRSpec.php
index c73974a..3a1e19c 100644
--- a/src/PeratX/SFQRCode/QRSpec.php
+++ b/src/PeratX/SFQRCode/QRSpec.php
@@ -435,79 +435,6 @@ public static function createFrame($version){
return $frame;
}
-
- public static function debug($frame, $binary_mode = false){
- if($binary_mode){
-
- foreach($frame as &$frameLine){
- $frameLine = join(' ', explode('0', $frameLine));
- $frameLine = join('██', explode('1', $frameLine));
- }
-
- ?>
-
-
';
- echo join("
", $frame);
- echo '
';
-
- }else{
-
- foreach($frame as &$frameLine){
- $frameLine = join(' ', explode("\xc0", $frameLine));
- $frameLine = join('▒', explode("\xc1", $frameLine));
- $frameLine = join(' ', explode("\xa0", $frameLine));
- $frameLine = join('▒', explode("\xa1", $frameLine));
- $frameLine = join('◇', explode("\x84", $frameLine)); //format 0
- $frameLine = join('◆', explode("\x85", $frameLine)); //format 1
- $frameLine = join('☢', explode("\x81", $frameLine)); //special bit
- $frameLine = join(' ', explode("\x90", $frameLine)); //clock 0
- $frameLine = join('◷', explode("\x91", $frameLine)); //clock 1
- $frameLine = join(' ', explode("\x88", $frameLine)); //version
- $frameLine = join('▒', explode("\x89", $frameLine)); //version
- $frameLine = join('♦', explode("\x01", $frameLine));
- $frameLine = join('⋅', explode("\0", $frameLine));
- }
-
- ?>
-
- ";
- echo join("
", $frame);
- echo "";
-
- }
- }
-
-
public static function serial($frame){
return gzcompress(join("\n", $frame), 9);
}
@@ -524,7 +451,7 @@ public static function newFrame($version){
if(!isset(self::$frames[$version])){
- $fileName = SFQRCode::QR_CACHE_DIR . 'frame_' . $version . '.dat';
+ $fileName = SFQRCode::getInstance()->getDataFolder() . 'frame_' . $version . '.dat';
if(SFQRCode::QR_CACHEABLE){
if(file_exists($fileName)){
diff --git a/src/PeratX/SFQRCode/SFQRCode.php b/src/PeratX/SFQRCode/SFQRCode.php
index e7554b3..a881674 100644
--- a/src/PeratX/SFQRCode/SFQRCode.php
+++ b/src/PeratX/SFQRCode/SFQRCode.php
@@ -62,6 +62,7 @@ class SFQRCode extends Module{
public function load(){
self::$obj = $this;
+ @mkdir($this->getDataFolder());
}
public static function getInstance(): SFQRCode{