// It shouldn't happen but it does - spaces in URL
$request['url'] = str_replace(' ', '+', $request['url']);
- $fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), true, ['timeout' => 10]);
+ $fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), ['timeout' => 10]);
$img_str = $fetchResult->getBody();
// If there is an error then return a blank image
}
$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());
// 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);