Fixing PHP warnings in qrcode.php

Signed-off-by: rdwebdesign <github@rdwebdesign.com.br>
This commit is contained in:
rdwebdesign
2021-12-27 23:42:56 -03:00
parent 88039aea1c
commit 4c8f869e7b
2 changed files with 17 additions and 11 deletions
+3 -1
View File
@@ -3,6 +3,7 @@
<style>
body {
background: #fff;
margin: 10px 0;
}
.qrcode {
@@ -32,7 +33,8 @@ if($auth) {
echo '<div class="qrcode">';
require_once("../../vendor/qrcode.php");
$qr = QRCode::getMinimumQRCode($pwhash, QR_ERROR_CORRECT_LEVEL_Q);
$qr->printSVG("10px");
// The size of each block (in pixels) should be an integer
$qr->printSVG(10);
echo "</div>";
echo 'Raw API Token: <code class="token">' . $pwhash . "</code></div>";
} else {
+14 -10
View File
@@ -64,24 +64,27 @@ class QRCode {
}
switch($mode) {
case QR_MODE_NUMBER :
$this->addDataImpl(new QRNumber($data) );
case QR_MODE_NUMBER:
$d = new QRNumber($data);
$this->addDataImpl($d);
break;
case QR_MODE_ALPHA_NUM :
$this->addDataImpl(new QRAlphaNum($data) );
case QR_MODE_ALPHA_NUM:
$d = new QRAlphaNum($data);
$this->addDataImpl($d);
break;
case QR_MODE_8BIT_BYTE :
$this->addDataImpl(new QR8BitByte($data) );
case QR_MODE_8BIT_BYTE:
$d = new QR8BitByte($data);
$this->addDataImpl($d);
break;
case QR_MODE_KANJI :
$this->addDataImpl(new QRKanji($data) );
case QR_MODE_KANJI:
$d = new QRKanji($data);
$this->addDataImpl($d);
break;
default :
default:
trigger_error("mode:$mode", E_USER_ERROR);
}
}
@@ -554,6 +557,7 @@ class QRCode {
public function printSVG($size = 2)
{
$size = (int) $size;
$width = $this->getModuleCount() * $size;
$height = $width;
print('<svg width="' . $width . '" height="' . $height . '" viewBox="0 0 ' . $width . ' ' . $height . '" xmlns="http://www.w3.org/2000/svg">');