]> git.mxchange.org Git - friendica.git/commitdiff
Code changes for #10020:
authorRoland Häder <roland@mxchange.org>
Tue, 9 Mar 2021 20:37:14 +0000 (21:37 +0100)
committerRoland Häder <roland@mxchange.org>
Thu, 11 Mar 2021 11:41:33 +0000 (12:41 +0100)
Added ability to set chmod (default: 0640) for "proxified" files (downloaded to
/proxy/ directory). This allows customization, e.g. if people want 0600 instead
without changing the code.

Signed-off-by: Roland Häder <roland@mxchange.org>
src/Module/Proxy.php
static/defaults.config.php

index f20b13bcef88e972a27cc4414f1627ef65039d2a..c7f7673b8a98516ff9374a487964387234f935e0 100644 (file)
@@ -131,7 +131,9 @@ class Proxy extends BaseModule
                // Store original image
                if ($direct_cache) {
                        // direct cache , store under ./proxy/
-                       file_put_contents($basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true), $image->asString());
+                       $filename = $basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true)
+                       file_put_contents($filename, $image->asString());
+                       chmod($filename, DI::config()->get('system', 'proxy_file_chmod', 0640));
                } elseif($cachefile !== '') {
                        // cache file
                        file_put_contents($cachefile, $image->asString());
@@ -149,7 +151,9 @@ class Proxy extends BaseModule
 
                // Store scaled image
                if ($direct_cache && $request['sizetype'] != '') {
-                       file_put_contents($basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true) . $request['sizetype'], $image->asString());
+                       $filename = $basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true) . $request['sizetype'];
+                       file_put_contents($filename, $image->asString());
+                       chmod($filename, DI::config()->get('system', 'proxy_file_chmod', 0640));
                }
 
                self::responseImageHttpCache($image);
index 7578e3c550bb07ea484b0249b9f738a5f1d5e48a..b075db36a06bada24930406869e72e30804419d6 100644 (file)
@@ -570,6 +570,10 @@ return [
                // xrd_timeout (Integer)
                // Timeout in seconds for fetching the XRD links.
                'xrd_timeout' => 20,
+
+               // proxy_file_chmod (Integer)
+               // Access rights for downloaded files in /proxy/ directory
+               'proxy_file_chmod' => 0640,
        ],
        'experimental' => [
                // exp_themes (Boolean)