Różnice między wybraną wersją a wersją aktualną.
Poprzednia rewizja po obu stronachPoprzednia wersjaNowa wersja | Poprzednia wersja | ||
narzedzia:qrcode_gen [2025/05/12 13:19] – administrator | narzedzia:qrcode_gen [2025/05/16 18:46] (aktualna) – administrator | ||
---|---|---|---|
Linia 1: | Linia 1: | ||
- | ====== QR code generator ====== | + | ====== |
+ | Prosty skrypt w PHP wykorzystujący bibliotekę [[https:// | ||
+ | Link do programu: | ||
+ | |||
+ | https:// | ||
+ | |||
+ | Dla wygenerowania kodu QR dla sieci wifi wystarczy zedytować i wkleić do generatora ten tekst: | ||
+ | |||
+ | < | ||
+ | WIFI: | ||
+ | </ | ||
+ | Wyjaśnienie: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Przykład: | ||
+ | |||
+ | < | ||
+ | WIFI: | ||
+ | </ | ||
+ | |||
+ | Kod rozwiązania: | ||
+ | |||
+ | <code php index.php> | ||
- | <code html index.php> | ||
<?php | <?php | ||
require_once ' | require_once ' | ||
- | header(' | ||
- | header(' | ||
- | header(' | ||
?> | ?> | ||
Linia 20: | Linia 41: | ||
< | < | ||
<form method=" | <form method=" | ||
- | Enter text or URL: <input type=" | + | Enter text or URL: <input type=" |
<button type=" | <button type=" | ||
</ | </ | ||
+ | < | ||
<?php | <?php | ||
Linia 28: | Linia 50: | ||
$text = $_POST[' | $text = $_POST[' | ||
$filename = ' | $filename = ' | ||
- | | + | |
+ | // Dynamically adjust the size based on the length of the input text | ||
+ | $dataLength = strlen($text); | ||
+ | $size = 5; // Default size | ||
+ | |||
+ | if ($dataLength <= 50) { | ||
+ | $size = 5; // Small amount of data | ||
+ | } elseif ($dataLength <= 100) { | ||
+ | $size = 6; // Medium amount of data | ||
+ | } elseif ($dataLength <= 200) { | ||
+ | $size = 7; // Larger data | ||
+ | } elseif ($dataLength <= 300) { | ||
+ | $size = 8; // Even larger data | ||
+ | } else { | ||
+ | $size = 9; // Very large data | ||
+ | } | ||
+ | |||
+ | // Create the QR code with the calculated size | ||
+ | | ||
echo "< | echo "< | ||
Linia 37: | Linia 77: | ||
</ | </ | ||
</ | </ | ||
- | </ | ||
+ | </ |