X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FPhoto.php;h=0e3661b0f33e4110915908a8542353e35823112b;hb=6bb418c5a7cdd71d28a8a572059efb14401b70bd;hp=68665126fb44c21aa26420ff3147bf87219e5d2b;hpb=85772f02cab76ba9666d7ba0775e5f04037755de;p=friendica.git diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 68665126fb..0e3661b0f3 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -16,6 +16,7 @@ use Friendica\Database\DBA; use Friendica\Database\DBStructure; use Friendica\Model\Storage\IStorage; use Friendica\Object\Image; +use Friendica\Protocol\DFRN; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\Security; @@ -129,12 +130,23 @@ class Photo extends BaseObject */ public static function getPhoto($resourceid, $scale = 0) { - $r = self::selectFirst(["uid"], ["resource-id" => $resourceid]); + $r = self::selectFirst(["uid", "allow_cid", "allow_gid", "deny_cid", "deny_gid"], ["resource-id" => $resourceid]); if ($r === false) { return false; } + $uid = $r["uid"]; + + // This is the first place, when retrieving just a photo, that we know who owns the photo. + // Check if the photo is public (empty allow and deny means public), if so, skip auth attempt, if not + // make sure that the requester's session is appropriately authenticated to that user + // otherwise permissions checks done by getPermissionsSQLByUserId() won't work correctly + if (!empty($r["allow_cid"]) || !empty($r["allow_gid"]) || !empty($r["deny_cid"]) || !empty($r["deny_gid"])) { + $r = DBA::selectFirst("user", ["nickname"], ["uid" => $uid], []); + // this will either just return (if auth all ok) or will redirect and exit (starting over) + DFRN::autoRedir(self::getApp(), $r["nickname"]); + } - $sql_acl = Security::getPermissionsSQLByUserId($r["uid"]); + $sql_acl = Security::getPermissionsSQLByUserId($uid); $conditions = [ "`resource-id` = ? AND `scale` <= ? " . $sql_acl,