2020-07-01 20:47:02 +02:00
|
|
|
<?php // ----- This file is included everywhere -----
|
|
|
|
|
|
|
|
require "config.inc.php";
|
|
|
|
|
2020-10-25 18:02:57 +01:00
|
|
|
$libreqrVersion = "1.3.0-dev";
|
|
|
|
|
|
|
|
// Defines the locale to be used
|
2020-10-12 18:48:53 +02:00
|
|
|
if ($forceLocale == false) {
|
|
|
|
$clientLocales = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
|
|
|
$clientLocales = preg_replace("#[A-Z0-9]|q=|;|-|\.#", "", $clientLocales);
|
|
|
|
$clientLocales = explode(',', $clientLocales);
|
|
|
|
$availableLocales = array('fr', 'en', 'template');
|
|
|
|
foreach ($clientLocales as $clientLocale) {
|
|
|
|
if (in_array($clientLocale, $availableLocales)) {
|
|
|
|
$locale = $clientLocale;
|
|
|
|
break;
|
|
|
|
}
|
2020-07-01 20:47:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
require "locales/" . $locale . ".php";
|
|
|
|
|
2020-10-12 18:48:53 +02:00
|
|
|
// Defines the root URL
|
2020-07-01 20:47:02 +02:00
|
|
|
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
|
|
|
|
$protocol = "https";
|
|
|
|
else
|
|
|
|
$protocol = "http";
|
2020-10-12 18:48:53 +02:00
|
|
|
$rootPath = $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
|
|
|
$rootPath = preg_replace('#\?.*$#', '', $rootPath);
|
|
|
|
$rootPath = preg_replace('#(manifest|opensearch|index).php$#i', '', $rootPath);
|
2020-07-01 20:47:02 +02:00
|
|
|
|
|
|
|
require "themes/" . $theme . "/theme.php"; // Load theme
|
|
|
|
|
2020-10-12 18:48:53 +02:00
|
|
|
// Used to generate the filename of the QR code
|
2020-07-01 20:47:02 +02:00
|
|
|
function generateRandomString($length) {
|
|
|
|
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
|
|
$charactersLength = strlen($characters);
|
|
|
|
$randomString = '';
|
|
|
|
for ($i = 0; $i < $length; $i++) {
|
|
|
|
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
|
|
|
}
|
|
|
|
return $randomString;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deletes images in temp/ older than the specified time in seconds
|
2020-10-25 18:02:57 +01:00
|
|
|
$files = array_diff(scandir("temp"), array('..', '.', '.gitkeep'));
|
|
|
|
foreach($files as $file) {
|
|
|
|
// If the current time (in Posix time) minus the date of last modification of the file is higher than specified time
|
|
|
|
if ((time() - filemtime("temp/" . $file)) > $timeBeforeDeletion) {
|
|
|
|
unlink("temp/" . $file); // Deletes this image
|
2020-07-01 20:47:02 +02:00
|
|
|
}
|
|
|
|
}
|