From 69d172a8d885cdcd544054cb32ade964bc241dc1 Mon Sep 17 00:00:00 2001 From: Miraty Date: Sat, 6 Nov 2021 00:33:15 +0100 Subject: [PATCH] Allow empty automatic sizes + better HTML semantics and forms --- inc.php | 6 +-- index.php | 138 ++++++++++++++++++++++++++----------------------- locales/en.php | 18 +++---- locales/fr.php | 18 +++---- locales/oc.php | 18 +++---- style.less | 8 +++ 6 files changed, 108 insertions(+), 98 deletions(-) diff --git a/inc.php b/inc.php index aa6adfd..cd80205 100644 --- a/inc.php +++ b/inc.php @@ -2,9 +2,9 @@ require "config.inc.php"; -define("DEFAULT_REDONDANCY", "H"); -define("DEFAULT_MARGIN", 10); -define("DEFAULT_SIZE", 100); +define("DEFAULT_REDONDANCY", "high"); +define("DEFAULT_MARGIN", NULL); +define("DEFAULT_SIZE", NULL); define("DEFAULT_BGCOLOR", "FFFFFF"); define("DEFAULT_MAINCOLOR", "000000"); diff --git a/index.php b/index.php index e127ca1..632fe38 100755 --- a/index.php +++ b/index.php @@ -53,11 +53,15 @@ if ( if (is_numeric($_POST['margin']) AND $_POST['margin'] >= 0 AND $_POST['margin'] <= 1024) $params['margin'] = $_POST['margin']; + else if (empty($_POST['margin'])) + $params['margin'] = NULL; else exit("Wrong value for margin"); - if (is_numeric($_POST['size']) AND $_POST['size'] >= 1 AND $_POST['size'] <= 1024) + if (is_numeric($_POST['size']) AND $_POST['size'] >= 1 AND $_POST['size'] <= 4096) $params['size'] = $_POST['size']; + else if (empty($_POST['size'])) + $params['size'] = NULL; else exit("Wrong value for size"); @@ -117,28 +121,24 @@ if (
- - +
+ +
+ +
+
+
- +
+ +

+ +

+
+
+ +

+ +

+
+ + +
- - +
+ +

+ +

+
+ + +
@@ -198,46 +206,46 @@ if ( -
+ setPadding($params['margin']); + $qrCode + ->setText($params['txt']) + ->setSize($params['size']) + ->setErrorCorrection($params['redondancy']) + ->setForegroundColor(array( + 'r' => hexdec(substr($params['mainColor'],0,2)), + 'g' => hexdec(substr($params['mainColor'],2,2)), + 'b' => hexdec(substr($params['mainColor'],4,2)), + )) + ->setBackgroundColor(array( + 'r' => hexdec(substr($params['bgColor'],0,2)), + 'g' => hexdec(substr($params['bgColor'],2,2)), + 'b' => hexdec(substr($params['bgColor'],4,2)), + )) + ->setImageType(QrCode::IMAGE_TYPE_PNG); + $dataUri = $qrCode->getDataUri(); + $qrSize = $qrCode->getSize() + 2 * $qrCode->getPadding(); - require "barcode-generator/Utils/QrCode.php"; + ?> - $qrCode = new QrCode(); - $qrCode - ->setText($params['txt']) - ->setSize($params['size']) - ->setPadding($params['margin']) - ->setErrorCorrection($params['redondancy']) - ->setForegroundColor(array( - 'r' => hexdec(substr($params['mainColor'],0,2)), - 'g' => hexdec(substr($params['mainColor'],2,2)), - 'b' => hexdec(substr($params['mainColor'],4,2)), - )) - ->setBackgroundColor(array( - 'r' => hexdec(substr($params['bgColor'],0,2)), - 'g' => hexdec(substr($params['bgColor'],2,2)), - 'b' => hexdec(substr($params['bgColor'],4,2)), - )) - ->setImageType(QrCode::IMAGE_TYPE_PNG); - $base64 = $qrCode->generate(); - - ?> +
- +
- - -
+ +