Browse Source

Move temp/ to css/ and remove old unused code

main
Miraty 1 month ago
parent
commit
57240e3631
  1. 3
      .gitignore
  2. 6
      README.md
  3. 6
      README_fr.md
  4. 0
      css/.gitkeep
  5. 20
      inc.php
  6. 19
      index.php
  7. 1
      temp/.gitkeep

3
.gitignore

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

6
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

6
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

0
css/.gitkeep

20
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
}
}

19
index.php

@ -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>

1
temp/.gitkeep

@ -1 +0,0 @@
Loading…
Cancel
Save