diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 445f5d54d..5d6536a8d 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -1,6 +1,7 @@ 1)) - { + if ($resolution == 2 && ($cookie_value > 1)) { $resolution = 1; - } + } } $r = q("SELECT uid, photo_usage FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1", dbesc($photo), intval($resolution) ); - if($r) { + if ($r) { $allowed = (-1); - if(intval($r[0]['photo_usage'])) { + if (intval($r[0]['photo_usage'])) { $allowed = 1; - if(intval($r[0]['photo_usage']) === PHOTO_COVER) - if($resolution < PHOTO_RES_COVER_1200) + if (intval($r[0]['photo_usage']) === PHOTO_COVER) { + if ($resolution < PHOTO_RES_COVER_1200) { $allowed = (-1); - if(intval($r[0]['photo_usage']) === PHOTO_PROFILE) - if(! in_array($resolution,[4,5,6])) + } + } + if (intval($r[0]['photo_usage']) === PHOTO_PROFILE) { + if (! in_array($resolution,[4,5,6])) { $allowed = (-1); + } + } } - if($allowed === (-1)) { + if ($allowed === (-1)) { $allowed = attach_can_view($r[0]['uid'],$observer_xchan,$photo); } @@ -211,32 +215,30 @@ class Photo extends \Zotlabs\Web\Controller { $exists = (($e) ? true : false); - if($exists && $allowed) { + if ($exists && $allowed) { $data = dbunescbin($e[0]['content']); $mimetype = $e[0]['mimetype']; - if(intval($e[0]['os_storage'])) { + if (intval($e[0]['os_storage'])) { $streaming = $data; } - if($e[0]['allow_cid'] != '' || $e[0]['allow_gid'] != '' || $e[0]['deny_gid'] != '' || $e[0]['deny_gid'] != '') + if ($e[0]['allow_cid'] != '' || $e[0]['allow_gid'] != '' || $e[0]['deny_gid'] != '' || $e[0]['deny_gid'] != '') $prvcachecontrol = 'no-store, no-cache, must-revalidate'; } else { - if(! $allowed) { + if (! $allowed) { http_status_exit(403,'forbidden'); } - if(! $exists) { + if (! $exists) { http_status_exit(404,'not found'); } - } } } - if(! isset($data)) { - if(isset($resolution)) { - switch($resolution) { - + if (! isset($data)) { + if (isset($resolution)) { + switch ($resolution) { case 4: $data = fetch_image_from_url(z_root() . '/' . get_default_profile_photo(),$mimetype); break; @@ -248,29 +250,27 @@ class Photo extends \Zotlabs\Web\Controller { break; default: killme(); - // NOTREACHED - break; } } } - if(isset($res) && intval($res) && $res < 500) { + if (isset($res) && intval($res) && $res < 500) { $ph = photo_factory($data, $mimetype); - if($ph->is_valid()) { + if ($ph->is_valid()) { $ph->scaleImageSquare($res); $data = $ph->imageString(); $mimetype = $ph->getType(); } } - if(function_exists('header_remove')) { + if (function_exists('header_remove')) { header_remove('Pragma'); header_remove('pragma'); } header("Content-type: " . $mimetype); - if($prvcachecontrol) { + if ($prvcachecontrol) { // it is a private photo that they have permission to view. // tell the browser and infrastructure caches not to cache it, @@ -290,9 +290,9 @@ class Photo extends \Zotlabs\Web\Controller { // leave it alone. $cache = get_config('system','photo_cache_time'); - if(! $cache) + if (! $cache) { $cache = (3600 * 24); // 1 day - + } header("Expires: " . gmdate("D, d M Y H:i:s", time() + $cache) . " GMT"); // Set browser cache age as $cache. But set timeout of 'shared caches' // much lower in some cases in the event that infrastructure caching is present. @@ -305,13 +305,15 @@ class Photo extends \Zotlabs\Web\Controller { // If it's a file resource, stream it. - if($streaming && $channel) { - if(strpos($streaming,'store') !== false) + if ($streaming && $channel) { + if (strpos($streaming,'store') !== false) { $istream = fopen($streaming,'rb'); - else + } + else { $istream = fopen('store/' . $channel['channel_address'] . '/' . $streaming,'rb'); + } $ostream = fopen('php://output','wb'); - if($istream && $ostream) { + if ($istream && $ostream) { pipe_streams($istream,$ostream); fclose($istream); fclose($ostream); @@ -320,7 +322,6 @@ class Photo extends \Zotlabs\Web\Controller { else { echo $data; } - killme(); }