1
0
Fork 0
forked from miraty/libreqr

Move temp/ to css/ and remove old unused code

This commit is contained in:
Miraty 2021-11-03 19:48:30 +01:00
parent 2f2ce4ab4f
commit 57240e3631
7 changed files with 14 additions and 41 deletions

3
.gitignore vendored
View file

@ -1,2 +1,3 @@
.directory
temp/*
css/*
!css/.gitkeep

View file

@ -31,11 +31,11 @@ GD extension is required.
`apt install php7.3-gd`
LibreQR need writing rights on the `temp/` directory.
LibreQR need writing rights on the `css/` directory.
```
chown -R www-data:www-data /var/www/libreqr/temp
chmod -R 600 /var/www/libreqr/temp
chown -R www-data:www-data /var/www/libreqr/css
chmod -R 600 /var/www/libreqr/css
```
### YunoHost

View file

@ -31,11 +31,11 @@ L'extension GD est requise.
`apt install php7.3-gd`
LibreQR a besoin des permissions d'écriture dans le dossier `temp/`.
LibreQR a besoin des permissions d'écriture dans le dossier `css/`.
```
chown -R www-data:www-data /var/www/libreqr/temp
chmod -R 600 /var/www/libreqr/temp
chown -R www-data:www-data /var/www/libreqr/css
chmod -R 600 /var/www/libreqr/css
```
### YunoHost

0
css/.gitkeep Normal file
View file

20
inc.php
View file

@ -35,23 +35,3 @@ $rootPath = preg_replace('#\?.*$#', '', $rootPath);
$rootPath = preg_replace('#(manifest|opensearch|index).php$#i', '', $rootPath);
require "themes/" . $theme . "/theme.php"; // Load theme
// Used to generate the filename of the QR code
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
$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
}
}

View file

@ -83,26 +83,19 @@ if (
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="manifest" href="manifest.php">
<link rel="search" type="application/opensearchdescription+xml" title="LibreQR" href="opensearch.php&#63;redondancy=<?= $params['redondancy'] ?>&amp;margin=<?= $params['margin'] ?>&amp;size=<?= $params['size'] ?>&amp;bgColor=<?= urlencode($params['bgColor']) ?>&amp;mainColor=<?= urlencode($params['mainColor']) ?>">
<?php
// If style.min.css exists
if (file_exists("temp/style.min.css"))
// And if it's older than theme.php or config.inc.php (so not up to date)
if (filemtime("themes/" . $theme . "/theme.php") > filemtime("temp/style.min.css") OR filemtime("config.inc.php") > filemtime("temp/style.min.css"))
// Then delete it
unlink("temp/style.min.css");
<?php
require_once "less.php/lib/Less/Autoloader.php";
Less_Autoloader::register();
$options = array('cache_dir' => 'temp/', 'compress' => true);
$options = array('cache_dir' => 'css/', 'compress' => true);
$cssFileName = Less_Cache::Get(array("style.less" => ""), $options, $colorScheme);
?>
<link type="text/css" rel="stylesheet" href="temp/<?= $cssFileName ?>">
<?php
<link type="text/css" rel="stylesheet" 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";
} ?>
}
?>
</head>
<body>

View file

@ -1 +0,0 @@