From 57240e3631d9263340cfcc1cdb9ea9afb1ad3416 Mon Sep 17 00:00:00 2001 From: Miraty Date: Wed, 3 Nov 2021 19:48:30 +0100 Subject: [PATCH] Move temp/ to css/ and remove old unused code --- .gitignore | 3 ++- README.md | 6 +++--- README_fr.md | 6 +++--- css/.gitkeep | 0 inc.php | 20 -------------------- index.php | 19 ++++++------------- temp/.gitkeep | 1 - 7 files changed, 14 insertions(+), 41 deletions(-) create mode 100644 css/.gitkeep delete mode 100755 temp/.gitkeep diff --git a/.gitignore b/.gitignore index 01fc22b..7598957 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .directory -temp/* +css/* +!css/.gitkeep diff --git a/README.md b/README.md index 835b055..87a2ba0 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/README_fr.md b/README_fr.md index 60149b0..d470fb1 100644 --- a/README_fr.md +++ b/README_fr.md @@ -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 diff --git a/css/.gitkeep b/css/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/inc.php b/inc.php index 570bbbd..aa6adfd 100644 --- a/inc.php +++ b/inc.php @@ -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 - } -} diff --git a/index.php b/index.php index 095735e..e127ca1 100755 --- a/index.php +++ b/index.php @@ -83,26 +83,19 @@ if ( - filemtime("temp/style.min.css") OR filemtime("config.inc.php") > filemtime("temp/style.min.css")) - // Then delete it - unlink("temp/style.min.css"); - + 'temp/', 'compress' => true); + $options = array('cache_dir' => 'css/', 'compress' => true); $cssFileName = Less_Cache::Get(array("style.less" => ""), $options, $colorScheme); - ?> - -"> + ' . "\n"; - } ?> + } + ?> diff --git a/temp/.gitkeep b/temp/.gitkeep deleted file mode 100755 index 8d1c8b6..0000000 --- a/temp/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -