summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorczaks <marcin@6irc.net>2014-07-06 01:24:16 +0200
committerczaks <marcin@6irc.net>2014-07-06 01:24:16 +0200
commit6a3dbe5c983e55adf098abe261d7ee100c16c2e6 (patch)
treeeaa36d67dfe328eb6e85a3bea65d2299c5a21eae
parent95bb7b84b77e6aea64d796627b61f8c016dc3a82 (diff)
parent1853efa883a8a45f27fdac25f7151c883253adfa (diff)
Merge 4.5
Conflicts: inc/display.php templates/post_reply.html templates/post_thread.html
-rw-r--r--README.md2
-rw-r--r--inc/functions.php24
2 files changed, 24 insertions, 2 deletions
diff --git a/README.md b/README.md
index c2d57135..bc2d8072 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ vichan is a free light-weight, fast, highly configurable and user-friendly
imageboard software package. It is written in PHP and has few dependencies.
vichan is a fork of [Tinyboard](http://tinyboard.org/), a great imageboard package, actively
-building on it and adding a lot of features and another improvements.
+building on it and adding a lot of features and other improvements.
Support and announcements: https://int.vichan.net/devel/
diff --git a/inc/functions.php b/inc/functions.php
index db9c91b0..70f15c59 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -1,7 +1,7 @@
<?php
/*
- * Copyright (c) 2010-2013 Tinyboard Development Group
+ * Copyright (c) 2010-2014 Tinyboard Development Group
*/
if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) {
@@ -546,6 +546,28 @@ function file_write($path, $data, $simple = false, $skip_purge = false) {
if (!fclose($fp))
error('Unable to close file: ' . $path);
+ /**
+ * Create gzipped file.
+ *
+ * When writing into a file foo.bar and the size is larger or equal to 1
+ * KiB, this also produces the gzipped version foo.bar.gz
+ *
+ * This is useful with nginx with gzip_static on.
+ */
+ if ($config['gzip_static']) {
+ $gzpath = "$path.gz";
+
+ if ($bytes & ~0x3ff) { // if ($bytes >= 1024)
+ if (file_put_contents($gzpath, gzencode($data), $simple ? 0 : LOCK_EX) === false)
+ error("Unable to write to file: $gzpath");
+ if (!touch($gzpath, filemtime($path), fileatime($path)))
+ error("Unable to touch file: $gzpath");
+ }
+ else {
+ @unlink($gzpath);
+ }
+ }
+
if (!$skip_purge && isset($config['purge'])) {
// Purge cache
if (basename($path) == $config['file_index']) {