New config.inc.php and fuse inc.php in index.php

This commit is contained in:
Miraty 2022-02-18 17:15:43 +01:00
parent 05da7e24a7
commit 8761d0e33a
6 changed files with 52 additions and 72 deletions

View file

@ -1,31 +1,20 @@
<?php // This file is part of LibreQR, which is distributed under the GNU AGPLv3+ license <?php // This file is part of LibreQR, which is distributed under the GNU AGPLv3+ license
// ----- Settings ----- // LIBREQR SETTINGS
// ----- Paramètres -----
// EN: Time in seconds after which the QR code will be deleted when a page loads. // Theme's directory name
// Default: 60 * 60 * 24 * 2 (two days) define("THEME", "contrast");
// FR : Temps en secondes après lequel le code QR sera supprimé lors du chargement d'une page.
// Par défaut : 60 * 60 * 24 * 2 (deux jours)
$timeBeforeDeletion = 60 * 60 * 24 * 2;
// EN: Theme's name (must be in the themes directory) // Language used if those requested by the user are not available
// FR : Nom du thème (doit être dans le dossier themes) define("DEFAULT_LOCALE", "en");
$theme = "libreqr";
// EN: Language used if those requested by the user are not available // Will be printed at the bottom of the interface
// FR : Langue utilisée si celles demandées par l'utilisateurice ne sont pas disponibles define("CUSTOM_TEXT_ENABLED", false);
$locale = "en"; define("CUSTOM_TEXT", "This LibreQR instance is hosted by <a href='https://foo.example/'>foo</a>.");
// EN: Should the locales requested by the user be ignored? // Default values
// FR : Faut-il ignorer les langues demandées par l'utilisateurice ? define("DEFAULT_REDUNDANCY", "high");
$forceLocale = false; define("DEFAULT_MARGIN", NULL);
define("DEFAULT_SIZE", NULL);
// EN: Lenght of the QR code filename define("DEFAULT_BGCOLOR", "FFFFFF");
// FR : Longueur du nom du fichier du code QR define("DEFAULT_MAINCOLOR", "000000");
$fileNameLenght = 32;
// EN: Will be printed at the bottom of the interface
// FR : Sera affiché en bas de l'interface
$customTextEnabled = false;
$customText = "This LibreQR instance is hosted by <a href='https://foo.example/'>foo</a>.";

39
inc.php
View file

@ -1,39 +0,0 @@
<?php // This file is part of LibreQR, which is distributed under the GNU AGPLv3+ license
// ----- This file is included everywhere -----
require "config.inc.php";
define("DEFAULT_REDUNDANCY", "high");
define("DEFAULT_MARGIN", NULL);
define("DEFAULT_SIZE", NULL);
define("DEFAULT_BGCOLOR", "FFFFFF");
define("DEFAULT_MAINCOLOR", "000000");
$libreqrVersion = "1.4.0dev";
// Defines the locale to be used
if ($forceLocale == false AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$clientLocales = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$clientLocales = preg_replace("#[A-Z0-9]|q=|;|-|\.#", "", $clientLocales);
$clientLocales = explode(',', $clientLocales);
$availableLocales = array('en', 'fr', 'oc', 'template');
foreach ($clientLocales as $clientLocale) {
if (in_array($clientLocale, $availableLocales)) {
$locale = $clientLocale;
break;
}
}
}
require "locales/" . $locale . ".php";
// Defines the root URL
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
$protocol = "https";
else
$protocol = "http";
$rootPath = $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$rootPath = preg_replace('#\?.*$#', '', $rootPath);
$rootPath = preg_replace('#(manifest|opensearch|index).php$#i', '', $rootPath);
require "themes/" . $theme . "/theme.php"; // Load theme

View file

@ -2,7 +2,37 @@
use CodeItNow\BarcodeBundle\Utils\QrCode; use CodeItNow\BarcodeBundle\Utils\QrCode;
require "inc.php"; require "config.inc.php";
define("LIBREQR_VERSION", "2.0.0dev");
// Defines the locale to be used
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$clientLocales = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$clientLocales = preg_replace("#[A-Z0-9]|q=|;|-|\.#", "", $clientLocales);
$clientLocales = explode(',', $clientLocales);
$availableLocales = array('en', 'fr', 'oc', 'template');
foreach ($clientLocales as $clientLocale) {
if (in_array($clientLocale, $availableLocales)) {
$locale = $clientLocale;
break;
}
}
} else {
$locale = DEFAULT_LOCALE;
}
require "locales/" . $locale . ".php";
// Defines the root URL
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
$protocol = "https";
else
$protocol = "http";
$rootPath = $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$rootPath = preg_replace('#\?.*$#', '', $rootPath);
$rootPath = preg_replace('#(manifest|opensearch|index).php$#i', '', $rootPath);
require "themes/" . THEME . "/theme.php"; // Load the theme
$params = array( $params = array(
"txt" => "", "txt" => "",
@ -78,7 +108,7 @@ if (
require_once "less.php/lib/Less/Autoloader.php"; require_once "less.php/lib/Less/Autoloader.php";
Less_Autoloader::register(); Less_Autoloader::register();
$colorScheme['theme'] = $theme; $colorScheme['theme'] = THEME;
$options = array('cache_dir' => 'css/', 'compress' => true); $options = array('cache_dir' => 'css/', 'compress' => true);
$cssFileName = Less_Cache::Get(array("style.less" => ""), $options, $colorScheme); $cssFileName = Less_Cache::Get(array("style.less" => ""), $options, $colorScheme);
@ -86,7 +116,7 @@ if (
<link rel="stylesheet" media="screen" href="css/<?= $cssFileName ?>"> <link rel="stylesheet" media="screen" href="css/<?= $cssFileName ?>">
<?php <?php
foreach($themeDimensionsIcons as $dimFav) { // Set all icons dimensions foreach($themeDimensionsIcons as $dimFav) { // Set all icons dimensions
echo ' <link rel="icon" type="image/png" href="themes/' . $theme . '/icons/' . $dimFav . '.png" sizes="' . $dimFav . 'x' . $dimFav . '">' . "\n"; echo ' <link rel="icon" type="image/png" href="themes/' . THEME . '/icons/' . $dimFav . '.png" sizes="' . $dimFav . 'x' . $dimFav . '">' . "\n";
} }
?> ?>
</head> </head>
@ -254,9 +284,9 @@ if (
<?= $loc['metaText_qr'] ?> <?= $loc['metaText_qr'] ?>
</section> </section>
<?php if ($customTextEnabled) { ?> <?php if (CUSTOM_TEXT_ENABLED) { ?>
<section class="metaText"> <section class="metaText">
<?= $customText ?> <?= CUSTOM_TEXT ?>
</section> </section>
<?php } ?> <?php } ?>

View file

@ -37,7 +37,7 @@ $loc = array(
A QR code is a 2 dimensional barcode in which text is written in binary. It can be decoded with a device equipped with a photo sensor and an adequate software. A QR code is a 2 dimensional barcode in which text is written in binary. It can be decoded with a device equipped with a photo sensor and an adequate software.
<a href='https://en.wikipedia.org/wiki/QR_code' hreflang='en' rel='help external noreferrer'>QR code on Wikipedia</a>. <a href='https://en.wikipedia.org/wiki/QR_code' hreflang='en' rel='help external noreferrer'>QR code on Wikipedia</a>.
", ",
'metaText_legal' => "LibreQR " . $libreqrVersion . " is a free software whose <a href='https://code.antopie.org/miraty/libreqr/' rel='external noreferrer'>source code</a> is available under the terms of the <abbr title='GNU Affero General Public License version 3 or any later version'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>.", 'metaText_legal' => "LibreQR " . LIBREQR_VERSION . " is a free software whose <a href='https://code.antopie.org/miraty/libreqr/' rel='external noreferrer'>source code</a> is available under the terms of the <abbr title='GNU Affero General Public License version 3 or any later version'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>.",
'opensearch_description' => "Generate QR codes from your search or address bar", 'opensearch_description' => "Generate QR codes from your search or address bar",
); );

View file

@ -37,7 +37,7 @@ $loc = array(
Un code QR est un code-barres en 2 dimensions dans lequel du texte est inscrit en binaire. Il peut être décodé avec un appareil muni d'un capteur photo et d'un logiciel adéquat. Un code QR est un code-barres en 2 dimensions dans lequel du texte est inscrit en binaire. Il peut être décodé avec un appareil muni d'un capteur photo et d'un logiciel adéquat.
<a href='https://fr.wikipedia.org/wiki/Code_QR' hreflang='fr' rel='help external noreferrer'>Code QR sur Wikipédia</a>. <a href='https://fr.wikipedia.org/wiki/Code_QR' hreflang='fr' rel='help external noreferrer'>Code QR sur Wikipédia</a>.
", ",
'metaText_legal' => "LibreQR " . $libreqrVersion . " est un logiciel libre dont le <a href='https://code.antopie.org/miraty/libreqr/' rel='external noreferrer'>code source</a> est disponible selon les termes de l'<abbr title='GNU Affero General Public License version 3 ou toute version ultérieure'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>.", 'metaText_legal' => "LibreQR " . LIBREQR_VERSION . " est un logiciel libre dont le <a href='https://code.antopie.org/miraty/libreqr/' rel='external noreferrer'>code source</a> est disponible selon les termes de l'<abbr title='GNU Affero General Public License version 3 ou toute version ultérieure'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>.",
'opensearch_description' => "Générez des codes QR depuis votre barre de recherche ou d'adresse", 'opensearch_description' => "Générez des codes QR depuis votre barre de recherche ou d'adresse",
); );

View file

@ -37,7 +37,7 @@ $loc = array(
Un còdi QR es un còdi de barras en doas dimensions dins lo qual lo tèxt es escrich en binari. Un aparalh equipat dun capteur optic pòt lo deschifrar, amb laplicacion que cal. Un còdi QR es un còdi de barras en doas dimensions dins lo qual lo tèxt es escrich en binari. Un aparalh equipat dun capteur optic pòt lo deschifrar, amb laplicacion que cal.
<a lang='ca' href='https://ca.wikipedia.org/wiki/Codi_QR' hreflang='ca' rel='help external noreferrer'>Còdi QR a la Wikipèdia</a>. <a lang='ca' href='https://ca.wikipedia.org/wiki/Codi_QR' hreflang='ca' rel='help external noreferrer'>Còdi QR a la Wikipèdia</a>.
", ",
'metaText_legal' => "LibreQR " . $libreqrVersion . " es un logicial liure que son <a href='https://code.antopie.org/miraty/libreqr/' rel='external noreferrer'>còdi font</a> es disponible jols tèrmes de la licéncia <abbr title='GNU Affero General Public License version 3 or any later version'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>.", 'metaText_legal' => "LibreQR " . LIBREQR_VERSION . " es un logicial liure que son <a href='https://code.antopie.org/miraty/libreqr/' rel='external noreferrer'>còdi font</a> es disponible jols tèrmes de la licéncia <abbr title='GNU Affero General Public License version 3 or any later version'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>.",
'opensearch_description' => "Generatz de còdis QR a partir de la barra de recèrca o dadreça", 'opensearch_description' => "Generatz de còdis QR a partir de la barra de recèrca o dadreça",
); );