]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Proxy.php
Prevent settings/userexport to be used by anonymous users
[friendica.git] / src / Module / Proxy.php
index f20b13bcef88e972a27cc4414f1627ef65039d2a..e43852baba0e8906890cb3be41f5261ca755b05b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -127,11 +127,16 @@ class Proxy extends BaseModule
                }
 
                $basepath = $a->getBasePath();
+               $filepermission = DI::config()->get('system', 'proxy_file_chmod');
 
                // 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());
+                       if (!empty($filepermission)) {
+                               chmod($filename, $filepermission);
+                       }
                } elseif($cachefile !== '') {
                        // cache file
                        file_put_contents($cachefile, $image->asString());
@@ -149,7 +154,11 @@ 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());
+                       if (!empty($filepermission)) {
+                               chmod($filename, $filepermission);
+                       }
                }
 
                self::responseImageHttpCache($image);