From 6ae97afa88da1178cd99fc20d2d0781c9be0a07b Mon Sep 17 00:00:00 2001 From: RobThree Date: Fri, 19 Sep 2014 09:52:20 +0200 Subject: [PATCH] * Default margin for GoogleQRCodeProvider changed from 4 to 1 * ECC level is no longer case-dependent * Minor 'optimization' for decodeColor in QRServerProvider --- src/TwoFactorAuth.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/TwoFactorAuth.php b/src/TwoFactorAuth.php index 83694e0..4eb060c 100644 --- a/src/TwoFactorAuth.php +++ b/src/TwoFactorAuth.php @@ -170,7 +170,7 @@ class GoogleQRCodeProvider extends BaseHTTPQRCodeProvider { public $errorcorrectionlevel; public $margin; - function __construct($verifyssl = false, $errorcorrectionlevel = 'L', $margin = 4) { + function __construct($verifyssl = false, $errorcorrectionlevel = 'L', $margin = 1) { if (!is_bool($verifyssl)) throw new Exception('VerifySSL must be bool'); @@ -241,14 +241,13 @@ class QRServerProvider extends BaseHTTPQRCodeProvider { } private function decodeColor($value) { - list($r, $g, $b) = sscanf($value, "%02x%02x%02x"); - return $r . '-' . $g . '-' . $b; + return vsprintf('%d-%d-%d', sscanf($value, "%02x%02x%02x")); } public function getUrl($qrtext, $size) { return 'https://api.qrserver.com/v1/create-qr-code/' . '?size=' . $size . 'x' . $size - . '&ecc=' . $this->errorcorrectionlevel + . '&ecc=' . strtoupper($this->errorcorrectionlevel) . '&margin=' . $this->margin . '&qzone=' . $this->qzone . '&bgcolor=' . $this->decodeColor($this->bgcolor) @@ -267,7 +266,7 @@ class QRicketProvider extends BaseHTTPQRCodeProvider { public $color; public $format; - function __construct($errorcorrectionlevel = 'l', $bgcolor = 'ffffff', $color = '000000', $format = 'p') { + function __construct($errorcorrectionlevel = 'L', $bgcolor = 'ffffff', $color = '000000', $format = 'p') { $this->verifyssl = false; $this->errorcorrectionlevel = $errorcorrectionlevel; @@ -295,7 +294,7 @@ class QRicketProvider extends BaseHTTPQRCodeProvider { public function getUrl($qrtext, $size) { return 'http://qrickit.com/api/qr' . '?qrsize=' . $size - . '&e=' . $this->errorcorrectionlevel + . '&e=' . strtolower($this->errorcorrectionlevel) . '&bgdcolor=' . $this->bgcolor . '&fgdcolor=' . $this->color . '&t=' . strtolower($this->format)