2019-08-13 21:17:08 +02:00
< ? php require " options.inc.php " ;
$locale = " fr_FR " ;
if ( defined ( 'LC_MESSAGES' )) {
setlocale ( LC_MESSAGES , $locale ); // Linux
bindtextdomain ( " messages " , " ./locale " );
} else {
putenv ( " LC_ALL= { $locale } " ); // windows
bindtextdomain ( " messages " , " ./locale " );
}
2019-02-24 19:11:31 +01:00
2019-02-11 19:26:31 +01:00
2019-08-13 21:17:08 +02:00
textdomain ( " messages " );
2019-02-11 19:26:31 +01:00
?>
2019-08-13 21:17:08 +02:00
<!--
_____ _ _ _ _____ ______
| __ \ // // | | | | | | | _ || ___ \
| | \ / ___ _ __ ___ _ __ __ _ | | _ ___ _ _ _ __ __ | | ___ ___ ___ __ | | ___ ___ | | | || | _ / /
| | __ / _ \ | '_ \ / _ \| ' __ | / _ ` || __| / _ \| | | || '__| / _` | / _ \ / __ | / _ \ / _ ` | / _ \ / __ | | | | || /
| | _\ \ | __ /| | | || __ /| | | ( _ | || | _ | __ /| | _ | || | | ( _ | || __ / | ( __ | ( _ ) || ( _ | || __ / \__ \ \ \ / ' /| | \ \
\____ / \___ || _ | | _ | \___ || _ | \__ , _ | \__ | \___ | \__ , _ || _ | \__ , _ | \___ | \___ | \___ / \__ , _ | \___ || ___ / \_ / \_\\_ | \_ |
Version 1.2 . 0 dev
Créé par Miraty et diffusé sous AGPLv3 +
Code source : https :// code . antopie . org / miraty / qr
-->
2019-01-26 14:23:19 +01:00
<! DOCTYPE HTML >
< html lang = " fr " >
< head >
2019-08-13 21:17:08 +02:00
< meta charset = " UTF-8 " >
2019-01-26 14:23:19 +01:00
< title > Générateur de codes QR </ title >
2019-08-13 21:17:08 +02:00
< meta name = " description " content = " Générez des codes QR librement. Choisissez le contenu, la taille, la couleur... " >
< meta name = " theme-color " content = " <?php echo $variablesTheme['fond'] ; ?> " >
2019-02-11 19:26:31 +01:00
< meta name = " viewport " content = " width=device-width, initial-scale=1 " >
2019-03-28 22:44:06 +01:00
< link rel = " manifest " href = " manifest.php " >
2019-08-13 21:17:08 +02:00
< link rel = " search " type = " application/opensearchdescription+xml " title = " Générer un code QR " href = " opensearch.php " >
Compil Less en PHP côté serveur + favicons thémés en plusieurs définitions
Le Less n'est plus compilé par le naigateur en JS, le serveur s'en
occupe en PHP. Le JS n'est donc plus nécessaire au fonctionnement du
générateur.
Les favions sont également thémés, et dans les dimensions suivantes :
16², 32², 48², 64², 96², 128², 192², 256², 384² et 512².
2019-02-22 22:23:02 +01:00
< style >
2019-08-13 21:17:08 +02:00
< ? php
$less -> setVariables ( $variablesTheme ); // Rends ces couleurs utilisables dans style.less
if ( $env == " prod " ) { // En production : minimise et met en cache style.less dans style.css
$less -> setFormatter ( " compressed " );
$less -> checkedCompile ( " style.less " , " style.css " );
echo file_get_contents ( " ubuntu/ubuntu.min.css " ) . file_get_contents ( " style.css " ); // Inclus toutes les CSS dans le document HTML (= moins de requêtes HTTP)
} else if ( $env == " dev " ) { // En développement : compile style.less a chaque chargement de page
echo file_get_contents ( " ubuntu/ubuntu.min.css " ) . $less -> compileFile ( " style.less " );
} else {
echo " Erreur : $env doit valoir prod ou dev dans options.inc.php " ;
} ?>
Compil Less en PHP côté serveur + favicons thémés en plusieurs définitions
Le Less n'est plus compilé par le naigateur en JS, le serveur s'en
occupe en PHP. Le JS n'est donc plus nécessaire au fonctionnement du
générateur.
Les favions sont également thémés, et dans les dimensions suivantes :
16², 32², 48², 64², 96², 128², 192², 256², 384² et 512².
2019-02-22 22:23:02 +01:00
</ style >
2019-08-13 21:17:08 +02:00
< ? php
foreach ( $themeDimensionsFavicons as $dimFav ) { // Indique toutes les dimensions de favicons
echo ' <link rel="icon" type="image/png" href="themes/' . $theme . '/favicons/' . $dimFav . '.png" sizes="' . $dimFav . 'x' . $dimFav . '">' . " \n " ;
} ?>
2019-01-26 14:23:19 +01:00
</ head >
2019-03-17 16:03:43 +01:00
< body lang = " fr " >
2019-01-26 14:23:19 +01:00
2019-03-17 16:03:43 +01:00
< header >
2019-08-13 21:17:08 +02:00
< a href = " <?php echo $cheminInstall ; ?> " >< img id = " logo " src = " themes/<?php echo $theme ; ?>/favicons/48.png " alt = " Logo de code QR " > < h1 >< ? php echo gettext ( " thisisatest " ); ?> Générateur de codes QR</h1></a>
2019-03-17 16:03:43 +01:00
</ header >
2019-08-13 21:17:08 +02:00
< ? php if ( ! isset ( $_GET [ " texte " ])) { // Si OpenSearch n'a pas été utilisé ?>
2019-03-17 16:03:43 +01:00
< form method = " post " >
2019-01-26 14:23:19 +01:00
2019-02-11 19:26:31 +01:00
< div class = " param " >
2019-08-13 21:17:08 +02:00
< label for = " texte " >< ? php echo gettext ( " ieatbanana " ); ?> Texte à encoder</label>
2019-02-11 19:26:31 +01:00
< span class = " conteneurAide " >
2019-08-13 21:17:08 +02:00
< span class = " boutonAide " >< ? php include " aide.svg " ; ?> </span>
2019-03-17 16:03:43 +01:00
< span class = " contenuAide " > Vous pouvez encoder ce que vous voulez sous forme de texte .</ span >
2019-02-11 19:26:31 +01:00
</ span >
< br >
2019-03-17 16:03:43 +01:00
< textarea rows = " 8 " required = " " id = " texte " placeholder = " Entrez le texte à encoder dans le code QR " name = " texte " >< ? php
2019-02-11 19:26:31 +01:00
2019-03-17 16:03:43 +01:00
if ( isset ( $_POST [ 'texte' ])) {
echo $_POST [ 'texte' ];
}
2019-02-11 19:26:31 +01:00
2019-03-17 16:03:43 +01:00
?> </textarea>
2019-02-11 19:26:31 +01:00
</ div >
2019-01-26 14:23:19 +01:00
2019-08-13 21:17:08 +02:00
< div id = " couleurs " >
< div class = " param " >
< label for = " couleurFond " > Couleur de fond </ label >
< span class = " conteneurAide " >
< span class = " boutonAide " >< ? php include " aide.svg " ; ?> </span>
< span class = " contenuAide " > Par combien les dimensions de l ' image seront - elles multipliées ? </ span >
</ span >
< br >
< div class = " conteneurInputColor " >
< input type = " color " name = " couleurFond " id = " couleurFond " value = " <?php if (isset( $_POST['couleurFond'] )) { echo $_POST['couleurFond'] ;} else { echo " #FFFFFF";} ?>">
</ div >
</ div >
< div class = " param " >
< label for = " couleurPrincipale " > Couleur de premier plan </ label >
< span class = " conteneurAide " >
< span class = " boutonAide " >< ? php include " aide.svg " ; ?> </span>
< span class = " contenuAide " > Nombre de pixels des bandes blanches autour du code QR .</ span >
</ span >
< br >
< div class = " conteneurInputColor " >
< input type = " color " name = " couleurPrincipale " id = " couleurPrincipale " value = " <?php if (isset( $_POST['couleurPrincipale'] )) { echo $_POST['couleurPrincipale'] ;} else { echo " #000000";} ?>">
</ div >
</ div >
</ div >
2019-03-17 16:03:43 +01:00
< div id = " menusDeroulants " >
< div class = " param " >
< label for = " taille " > Taille de l ' image </ label >
< span class = " conteneurAide " >
2019-08-13 21:17:08 +02:00
< span class = " boutonAide " >< ? php include " aide.svg " ; ?> </span>
2019-03-17 16:03:43 +01:00
< span class = " contenuAide " > Par combien les dimensions de l ' image seront - elles multipliées ? </ span >
</ span >
< br >
< select id = " taille " name = " taille " >
< option < ? php if ( isset ( $_POST [ 'taille' ]) AND ( $_POST [ 'taille' ] == 1 )) { echo 'selected="" ' ;} ?> value="1">1</option>
< option < ? php if ( isset ( $_POST [ 'taille' ]) AND ( $_POST [ 'taille' ] == 2 )) { echo 'selected="" ' ;} ?> value="2">2</option>
< option < ? php if ( isset ( $_POST [ 'taille' ]) AND ( $_POST [ 'taille' ] == 3 )) { echo 'selected="" ' ;} ?> value="3">3</option>
< option < ? php if (( isset ( $_POST [ 'taille' ]) AND ( $_POST [ 'taille' ] == 4 )) OR ( ! isset ( $_POST [ 'taille' ]))) { echo 'selected="" ' ;} ?> value="4">4 - par défaut</option>
< option < ? php if ( isset ( $_POST [ 'taille' ]) AND ( $_POST [ 'taille' ] == 5 )) { echo 'selected="" ' ;} ?> value="5">5</option>
< option < ? php if ( isset ( $_POST [ 'taille' ]) AND ( $_POST [ 'taille' ] == 6 )) { echo 'selected="" ' ;} ?> value="6">6</option>
< option < ? php if ( isset ( $_POST [ 'taille' ]) AND ( $_POST [ 'taille' ] == 7 )) { echo 'selected="" ' ;} ?> value="7">7</option>
< option < ? php if ( isset ( $_POST [ 'taille' ]) AND ( $_POST [ 'taille' ] == 8 )) { echo 'selected="" ' ;} ?> value="8">8</option>
< option < ? php if ( isset ( $_POST [ 'taille' ]) AND ( $_POST [ 'taille' ] == 10 )) { echo 'selected="" ' ;} ?> value="10">10</option>
2019-08-13 21:17:08 +02:00
< option < ? php if ( isset ( $_POST [ 'taille' ]) AND ( $_POST [ 'taille' ] == 15 )) { echo 'selected="" ' ;} ?> value="15">15</option>
2019-03-17 16:03:43 +01:00
< option < ? php if ( isset ( $_POST [ 'taille' ]) AND ( $_POST [ 'taille' ] == 20 )) { echo 'selected="" ' ;} ?> value="20">20</option>
</ select >
</ div >
< div class = " param " >
< label for = " redondance " > Taux de redondance </ label >
2019-08-13 21:17:08 +02:00
< span class = " conteneurAide " >
< span class = " boutonAide " >< ? php include " aide.svg " ; ?> </span>
< span class = " contenuAide " > La redondance est le " doublement " des informations dans le code QR afin de corriger les erreurs lors du décodage . Un taux plus élevé produira un code QR plus grand , mais aura plus de chance d ' être décodé correctement .</ span >
</ span >
2019-03-17 16:03:43 +01:00
< br >
< select id = " redondance " name = " redondance " >
< option < ? php if ( isset ( $_POST [ 'redondance' ]) AND ( $_POST [ 'redondance' ] == " L " )) { echo 'selected="" ' ;} ?> value="L">L - 7% de redondance</option>
< option < ? php if ( isset ( $_POST [ 'redondance' ]) AND ( $_POST [ 'redondance' ] == " M " )) { echo 'selected="" ' ;} ?> value="M">M - 15% de redondance</option>
< option < ? php if ( isset ( $_POST [ 'redondance' ]) AND ( $_POST [ 'redondance' ] == " Q " )) { echo 'selected="" ' ;} ?> value="Q">Q - 25% de redondance</option>
< option < ? php if (( isset ( $_POST [ 'redondance' ]) AND ( $_POST [ 'redondance' ] == " H " )) OR ( ! isset ( $_POST [ 'redondance' ]))) { echo 'selected="" ' ;} ?> value="H">H - 30% de redondance</option>
</ select >
</ div >
< div class = " param " >
< label for = " marge " > Taille de la marge </ label >
< span class = " conteneurAide " >
2019-08-13 21:17:08 +02:00
< span class = " boutonAide " >< ? php include " aide.svg " ; ?> </span>
2019-03-17 16:03:43 +01:00
< span class = " contenuAide " > Nombre de pixels des bandes blanches autour du code QR .</ span >
</ span >
< br >
< select id = " marge " name = " marge " >
< option < ? php if ( isset ( $_POST [ 'marge' ]) AND ( $_POST [ 'marge' ] == " 0 " )) { echo 'selected="" ' ;} ?> value="0">0</option>
< option < ? php if ( isset ( $_POST [ 'marge' ]) AND ( $_POST [ 'marge' ] == " 1 " )) { echo 'selected="" ' ;} ?> value="1">1</option>
< option < ? php if (( isset ( $_POST [ 'marge' ]) AND ( $_POST [ 'marge' ] == " 2 " )) OR ( ! isset ( $_POST [ 'marge' ]))) { echo 'selected="" ' ;} ?> value="2">2 - par défaut</option>
< option < ? php if ( isset ( $_POST [ 'marge' ]) AND ( $_POST [ 'marge' ] == " 3 " )) { echo 'selected="" ' ;} ?> value="3">3</option>
< option < ? php if ( isset ( $_POST [ 'marge' ]) AND ( $_POST [ 'marge' ] == " 5 " )) { echo 'selected="" ' ;} ?> value="5">5</option>
< option < ? php if ( isset ( $_POST [ 'marge' ]) AND ( $_POST [ 'marge' ] == " 10 " )) { echo 'selected="" ' ;} ?> value="10">10</option>
</ select >
</ div >
2019-01-26 14:23:19 +01:00
2019-03-17 16:03:43 +01:00
</ div >
2019-08-13 21:17:08 +02:00
< br >
2019-01-26 14:23:19 +01:00
2019-03-17 16:03:43 +01:00
< div class = " centrer " >
2019-08-13 21:17:08 +02:00
< input type = " submit " class = " bouton " value = " Générer " />
2019-03-17 16:03:43 +01:00
</ div >
2019-08-13 21:17:08 +02:00
< br >
< br >
2019-02-11 19:26:31 +01:00
2019-03-17 16:03:43 +01:00
</ form >
2019-02-11 19:26:31 +01:00
2019-03-17 16:03:43 +01:00
< ? php
2019-02-11 19:26:31 +01:00
2019-08-13 21:17:08 +02:00
if ( isset ( $_POST [ 'texte' ]) AND isset ( $_POST [ 'taille' ]) AND isset ( $_POST [ 'redondance' ]) AND isset ( $_POST [ 'marge' ]) AND isset ( $_POST [ 'couleurFond' ]) AND isset ( $_POST [ 'couleurPrincipale' ])) {
require " phpqrcode.php " ;
2019-02-11 19:26:31 +01:00
2019-03-17 16:03:43 +01:00
$cheminImage = " temp/ " . generateRandomString ( 50 ) . " .png " ;
2019-02-11 19:26:31 +01:00
2019-08-13 21:17:08 +02:00
QRcode :: png ( $_POST [ 'texte' ], $cheminImage , $_POST [ 'redondance' ], $_POST [ 'taille' ], $_POST [ 'marge' ], false , hexdec ( $_POST [ 'couleurFond' ]), hexdec ( $_POST [ 'couleurPrincipale' ])); ?>
2019-02-11 19:26:31 +01:00
2019-03-17 16:03:43 +01:00
< div class = " centrer " >
< a href = " <?php echo $cheminImage ; ?> " class = " bouton " download = " <?php echo htmlspecialchars( $_POST['texte'] ); ?>.png " > Télécharger ce code QR </ a >
</ div >
< br >< br >
< div class = " centrer " >
2019-08-13 21:17:08 +02:00
< a title = " Cliquez pour afficher uniquement ce code QR " href = " <?php echo $cheminImage ; ?> " >< img alt = 'Un code QR contenant "<?php echo htmlspecialchars($_POST[' texte ']); ?>"' id = " codeQR " src = " <?php echo $cheminImage ; ?> " /></ a >
2019-03-17 16:03:43 +01:00
</ div >
< ? php
}
?>
2019-02-11 19:26:31 +01:00
2019-03-17 16:03:43 +01:00
< ? php } else if ( isset ( $_GET [ " texte " ])) { // Si OpenSearch a été utilisé
2019-02-11 19:26:31 +01:00
2019-03-17 16:03:43 +01:00
if ( empty ( $_GET [ " texte " ])) { // Si rien n'a été recherché ?>
2019-02-11 19:26:31 +01:00
2019-03-17 16:03:43 +01:00
< span style = " font-size: 30px; " > Erreur : vous ne pouvez pas générer un code QR vide !
2019-02-11 19:26:31 +01:00
2019-08-13 21:17:08 +02:00
< ? php } else {
2019-02-11 19:26:31 +01:00
2019-08-13 21:17:08 +02:00
require " phpqrcode.php " ;
2019-03-17 16:03:43 +01:00
$cheminImage = " temp/ " . generateRandomString ( 50 ) . " .png " ;
2019-02-11 19:26:31 +01:00
2019-03-17 16:03:43 +01:00
QRcode :: png ( $_GET [ 'texte' ], $cheminImage , " H " , 4 , 2 ); ?>
2019-02-11 19:26:31 +01:00
2019-08-13 21:17:08 +02:00
< br >
Vous avez créé un code QR contenant :
< div class = " contenuQR " >< ? php echo htmlspecialchars ( $_GET [ 'texte' ]); ?> </div>
2019-03-28 22:44:06 +01:00
< br >
2019-03-17 16:03:43 +01:00
< div class = " centrer " >
< a href = " <?php echo $cheminImage ; ?> " class = " bouton " download = " <?php echo htmlspecialchars( $_GET['texte'] ); ?>.png " > Télécharger ce code QR </ a >
</ div >
< br >< br >
< div class = " centrer " >
2019-08-13 21:17:08 +02:00
< a title = " Cliquez pour afficher uniquement ce code QR " href = " <?php echo $cheminImage ; ?> " >< img alt = 'Un code QR contenant "<?php echo htmlspecialchars($_GET[' texte ']); ?>"' id = " codeQR " src = " <?php echo $cheminImage ; ?> " /></ a >
2019-03-17 16:03:43 +01:00
</ div >
2019-02-11 19:26:31 +01:00
2019-03-28 22:44:06 +01:00
2019-02-11 19:26:31 +01:00
2019-03-17 16:03:43 +01:00
< ? php } } ?>
2019-02-11 19:26:31 +01:00
2019-08-13 21:17:08 +02:00
< section class = " info " >
< strong > Qu 'est-ce qu' un code QR ? </ strong >< br >
Un code QR est une image en 2 dimensions dans laquelle est inscrite en binaire des informations textuelles .< br >
Un pixel blanc représente un 0 et un pixel noir représente un 1. < br >
< a href = " https://fr.wikipedia.org/wiki/Code_QR " > Code QR sur Wikipédia </ a >
</ section >
< footer >
< a class = " topRight " href = " https://code.antopie.org/miraty/qr/ " > Code source </ a >
</ footer >
2019-02-11 19:26:31 +01:00
2019-03-17 16:03:43 +01:00
</ body >
</ html >