diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
commit | 75160b12821f7f4299cce7f0b69c83c1502ae071 (patch) | |
tree | 27e25e4ccaef45f0c58b22831164050d1af1d4db /admin/survey/minify/static | |
parent | prvi-commit (diff) | |
download | 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip |
Diffstat (limited to '')
-rw-r--r-- | admin/survey/minify/static/.htaccess | 80 | ||||
-rw-r--r-- | admin/survey/minify/static/gen.php | 4 | ||||
-rw-r--r-- | admin/survey/minify/static/lib.php | 12 |
3 files changed, 50 insertions, 46 deletions
diff --git a/admin/survey/minify/static/.htaccess b/admin/survey/minify/static/.htaccess index f9cc303..36927be 100644 --- a/admin/survey/minify/static/.htaccess +++ b/admin/survey/minify/static/.htaccess @@ -1,40 +1,40 @@ -<IfModule mod_expires.c> - ExpiresActive On - ExpiresDefault "access plus 1 year" -</IfModule> - -<FilesMatch "\.(js|css|less)$"> - FileETag MTime Size -</FilesMatch> - -<IfModule mod_gzip.c> - mod_gzip_on yes - mod_gzip_dechunk yes - mod_gzip_keep_workfiles No - mod_gzip_minimum_file_size 1000 - mod_gzip_maximum_file_size 1000000 - mod_gzip_maximum_inmem_size 1000000 - mod_gzip_item_include mime ^text/.* - mod_gzip_item_include mime ^application/javascript$ - mod_gzip_item_include mime ^application/x-javascript$ - # Exclude old browsers and images since IE has trouble with this - mod_gzip_item_exclude reqheader "User-Agent: .*Mozilla/4\..*\[" - mod_gzip_item_exclude mime ^image/.* -</IfModule> - -<IfModule mod_deflate.c> - AddOutputFilterByType DEFLATE text/css text/javascript application/javascript application/x-javascript - BrowserMatch ^Mozilla/4 gzip-only-text/html - BrowserMatch ^Mozilla/4\.[0678] no-gzip - BrowserMatch \bMSIE !no-gzip -</IfModule> - -<IfModule mod_rewrite.c> -RewriteEngine on - -# You may need RewriteBase on some servers -#RewriteBase /min/static - -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^(.*)$ gen.php [QSA,L] -</IfModule> +<IfModule mod_expires.c>
+ ExpiresActive On
+ ExpiresDefault "access plus 1 year"
+</IfModule>
+
+<FilesMatch "\.(js|css|less)$">
+ FileETag MTime Size
+</FilesMatch>
+
+<IfModule mod_gzip.c>
+ mod_gzip_on yes
+ mod_gzip_dechunk yes
+ mod_gzip_keep_workfiles No
+ mod_gzip_minimum_file_size 1000
+ mod_gzip_maximum_file_size 1000000
+ mod_gzip_maximum_inmem_size 1000000
+ mod_gzip_item_include mime ^text/.*
+ mod_gzip_item_include mime ^application/javascript$
+ mod_gzip_item_include mime ^application/x-javascript$
+ # Exclude old browsers and images since IE has trouble with this
+ mod_gzip_item_exclude reqheader "User-Agent: .*Mozilla/4\..*\["
+ mod_gzip_item_exclude mime ^image/.*
+</IfModule>
+
+<IfModule mod_deflate.c>
+ AddOutputFilterByType DEFLATE text/css text/javascript application/javascript application/x-javascript
+ BrowserMatch ^Mozilla/4 gzip-only-text/html
+ BrowserMatch ^Mozilla/4\.[0678] no-gzip
+ BrowserMatch \bMSIE !no-gzip
+</IfModule>
+
+<IfModule mod_rewrite.c>
+RewriteEngine on
+
+# You may need RewriteBase on some servers
+#RewriteBase /min/static
+
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^(.*)$ gen.php [QSA,L]
+</IfModule>
diff --git a/admin/survey/minify/static/gen.php b/admin/survey/minify/static/gen.php index 2bc40af..5ec84a5 100644 --- a/admin/survey/minify/static/gen.php +++ b/admin/survey/minify/static/gen.php @@ -7,12 +7,12 @@ if (is_file(__DIR__ . '/bootstrap.php')) { $bootstrap_file = __DIR__ . '/../bootstrap.php';
}
-$send_400 = function($content = 'Bad URL') {
+$send_400 = function ($content = 'Bad URL') {
http_response_code(400);
die($content);
};
-$send_301 = function($url) {
+$send_301 = function ($url) {
http_response_code(301);
header("Cache-Control: max-age=31536000");
header("Location: $url");
diff --git a/admin/survey/minify/static/lib.php b/admin/survey/minify/static/lib.php index 32c6df5..3cd02d6 100644 --- a/admin/survey/minify/static/lib.php +++ b/admin/survey/minify/static/lib.php @@ -10,7 +10,8 @@ namespace Minify\StaticService; * @param string $type "css" or "js"
* @return string
*/
-function build_uri($static_uri, $query, $type) {
+function build_uri($static_uri, $query, $type)
+{
$static_uri = rtrim($static_uri, '/');
$query = ltrim($query, '?');
@@ -30,7 +31,8 @@ function build_uri($static_uri, $query, $type) { * @param bool $auto_create Automatically create the directory if missing?
* @return null|string null if missing or can't create
*/
-function get_cache_time($auto_create = true) {
+function get_cache_time($auto_create = true)
+{
foreach (scandir(__DIR__) as $entry) {
if (ctype_digit($entry)) {
return $entry;
@@ -50,14 +52,16 @@ function get_cache_time($auto_create = true) { return $time;
}
-function flush_cache() {
+function flush_cache()
+{
$time = get_cache_time(false);
if ($time) {
remove_tree(__DIR__ . "/$time");
}
}
-function remove_tree($dir) {
+function remove_tree($dir)
+{
$files = array_diff(scandir($dir), array('.', '..'));
foreach ($files as $file) {
|