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
// ----- Settings -----
// ----- Paramètres -----
// LIBREQR SETTINGS
// EN: Time in seconds after which the QR code will be deleted when a page loads.
// Default: 60 * 60 * 24 * 2 (two days)
// 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;
// Theme's directory name
define("THEME", "contrast");
// EN: Theme's name (must be in the themes directory)
// FR : Nom du thème (doit être dans le dossier themes)
$theme = "libreqr";
// Language used if those requested by the user are not available
define("DEFAULT_LOCALE", "en");
// EN: Language used if those requested by the user are not available
// FR : Langue utilisée si celles demandées par l'utilisateurice ne sont pas disponibles
$locale = "en";
// Will be printed at the bottom of the interface
define("CUSTOM_TEXT_ENABLED", false);
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?
// FR : Faut-il ignorer les langues demandées par l'utilisateurice ?
$forceLocale = false;
// EN: Lenght of the QR code filename
// FR : Longueur du nom du fichier du code QR
$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>.";
// Default values
define("DEFAULT_REDUNDANCY", "high");
define("DEFAULT_MARGIN", NULL);
define("DEFAULT_SIZE", NULL);
define("DEFAULT_BGCOLOR", "FFFFFF");
define("DEFAULT_MAINCOLOR", "000000");

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;
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(
"txt" => "",
@ -78,7 +108,7 @@ if (
require_once "less.php/lib/Less/Autoloader.php";
Less_Autoloader::register();
$colorScheme['theme'] = $theme;
$colorScheme['theme'] = THEME;
$options = array('cache_dir' => 'css/', 'compress' => true);
$cssFileName = Less_Cache::Get(array("style.less" => ""), $options, $colorScheme);
@ -86,7 +116,7 @@ if (
<link rel="stylesheet" media="screen" href="css/<?= $cssFileName ?>">
<?php
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>
@ -254,9 +284,9 @@ if (
<?= $loc['metaText_qr'] ?>
</section>
<?php if ($customTextEnabled) { ?>
<?php if (CUSTOM_TEXT_ENABLED) { ?>
<section class="metaText">
<?= $customText ?>
<?= CUSTOM_TEXT ?>
</section>
<?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 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",
);

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.
<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",
);

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.
<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",
);