Narzędzia użytkownika

Narzędzia witryny


narzedzia:qrcode_gen

Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

Poprzednia rewizja po obu stronachPoprzednia wersja
Nowa wersja
Poprzednia wersja
narzedzia:qrcode_gen [2025/05/12 13:19] administratornarzedzia:qrcode_gen [2025/05/16 18:46] (aktualna) administrator
Linia 1: Linia 1:
-====== QR code generator ======+====== PHP: QR code generator ======
  
 +Prosty skrypt w PHP wykorzystujący bibliotekę [[https://phpqrcode.sourceforge.net/|phpqrcode]] do generowania kodów QR
  
 +Link do programu:
 +
 +https://wiki.ostrowski.net.pl/qrcode/
 +
 +Dla wygenerowania kodu QR dla sieci wifi wystarczy zedytować i wkleić do generatora ten tekst:
 +
 +<code>
 +WIFI:T:<encryption>;S:<SSID>;P:<password>;H:<hidden>;;
 +</code>
 +Wyjaśnienie:
 +  * ''T'': Rodzaj szyfrowania (WPA, WPA2, WPA3, WEP, or nopass for open networks)
 +  * ''S'': SSID (nazwa sieci WiFi)
 +  * ''P'': Hasło
 +  * ''H'': ukryty SSID (true false)
 +
 +Przykład:
 +
 +<code>
 +WIFI:T:WPA;S:quest-network;P:pass1234;;
 +</code>
 +
 +Kod rozwiązania:
 +
 +<code php index.php>
  
-<code index.php html> 
 <?php <?php
 require_once './phpqrcode/qrlib.php'; // include the QR library require_once './phpqrcode/qrlib.php'; // include the QR library
-header('Cache-Control: no-cache, must-revalidate');  // Disable caching 
-header('Expires: 0');                               // Set expiration to 0 
-header('Pragma: no-cache');                         // Disable cache for older browsers 
  
 ?> ?>
Linia 20: Linia 41:
     <h2>QR Code Generator</h2>     <h2>QR Code Generator</h2>
     <form method="post">     <form method="post">
-        Enter text or URL: <input type="text" name="text" required>+        Enter text or URL: <input type="text" name="text" required style="width: 400px;">
         <button type="submit">Generate QR Code</button>         <button type="submit">Generate QR Code</button>
     </form>     </form>
 + <p>if you want wifi qrcode then edit and paste this: <tt>WIFI:T:WPA;S:quest-network;P:pass1234;;</tt></p>
  
     <?php     <?php
Linia 28: Linia 50:
         $text = $_POST['text'];         $text = $_POST['text'];
         $filename = 'qrcode.png';         $filename = 'qrcode.png';
-        QRcode::png($text, $filename, QR_ECLEVEL_L, 5);+ 
 +        // 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 
 +        QRcode::png($text, $filename, QR_ECLEVEL_L, $size);
  
         echo "<h3>Your QR Code:</h3>";         echo "<h3>Your QR Code:</h3>";
Linia 37: Linia 77:
 </body> </body>
 </html> </html>
-</php> 
  
 +</code>
narzedzia/qrcode_gen.1747048754.txt.gz · ostatnio zmienione: 2025/05/12 13:19 przez administrator