X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContact%2FAvatar.php;h=38208a043efe94799dd2c0edda5adf49c98fcf30;hb=65b86fe0d556829c09e8c8f5c707b868ad37dfe1;hp=63775609626a9d7bed13a7134f7e240ce47217be;hpb=34030a736d5e0aa2195c0f472cf69f863c161d83;p=friendica.git diff --git a/src/Contact/Avatar.php b/src/Contact/Avatar.php index 6377560962..38208a043e 100644 --- a/src/Contact/Avatar.php +++ b/src/Contact/Avatar.php @@ -123,20 +123,34 @@ class Avatar // Check directory permissions of all parts of the path foreach (explode('/', dirname($filename)) as $part) { $dirpath .= $part . '/'; + if (!file_exists($dirpath)) { - mkdir($dirpath, $dir_perm); - } elseif (fileperms($dirpath) & 0777 != $dir_perm) { - chmod($dirpath, $dir_perm); + if (!mkdir($dirpath, $dir_perm)) { + Logger::warning('Directory could not be created', ['directory' => $dirpath]); + } + } elseif ((($old_perm = fileperms($dirpath) & 0777) != $dir_perm) && !chmod($dirpath, $dir_perm)) { + Logger::notice('Directory permissions could not be changed', ['directory' => $dirpath, 'old' => $old_perm, 'new' => $dir_perm]); } - if (filegroup($dirpath) != $group) { - chgrp($dirpath, $group); + if ((($old_group = filegroup($dirpath)) != $group) && !chgrp($dirpath, $group)) { + Logger::notice('Directory group could not be changed', ['directory' => $dirpath, 'old' => $old_group, 'new' => $group]); } } - file_put_contents($filepath, $image->asString()); - chmod($filepath, $file_perm); - chgrp($filepath, $group); + if (!file_put_contents($filepath, $image->asString())) { + Logger::warning('File could not be created', ['file' => $filepath]); + } + + $old_perm = fileperms($filepath) & 0666; + $old_group = filegroup($filepath); + + if (($old_perm != $file_perm) && !chmod($filepath, $file_perm)) { + Logger::notice('File permissions could not be changed', ['file' => $filepath, 'old' => $old_perm, 'new' => $file_perm]); + } + + if (($old_group != $group) && !chgrp($filepath, $group)) { + Logger::notice('File group could not be changed', ['file' => $filepath, 'old' => $old_group, 'new' => $group]); + } DI::profiler()->stopRecording();