/** * Get user profile photo * * @return mixed data; */ function get_profile_photo($user, $size) { if (!$user instanceof OssnUser) { return false; } if (isset($size) && array_key_exists($size, ossn_user_image_sizes())) { $isize = "{$size}_"; } $photo = $user->getProfilePhoto(); $etag = $photo->guid . $photo->time_created; if (isset($photo->time_created)) { header("Last-Modified: " . gmdate('D, d M Y H:i:s \\G\\M\\T', $photo->time_created)); } header("Etag: {$etag}"); if (isset($photo->guid) && isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"{$etag}\"") { header("HTTP/1.1 304 Not Modified"); exit; } if (isset($photo->value) && !empty($photo->value)) { $datadir = ossn_get_userdata("user/{$user->guid}/{$photo->value}"); if (!empty($size)) { $image = str_replace('profile/photo/', '', $photo->value); $datadir = ossn_get_userdata("user/{$user->guid}/profile/photo/{$isize}{$image}"); } } else { $datadir = ossn_default_theme() . "images/nopictures/users/{$size}.jpg"; } $filesize = filesize($datadir); header("Content-type: image/jpeg"); header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime("+6 months")), true); header("Pragma: public"); header("Cache-Control: public"); header("Content-Length: {$filesize}"); header("ETag: \"{$etag}\""); readfile($datadir); return; }
/** * Open Source Social Network * * @package (Informatikon.com).ossn * @author OSSN Core Team <*****@*****.**> * @copyright 2014 iNFORMATIKON TECHNOLOGIES * @license General Public Licence http://www.opensource-socialnetwork.org/licence * @link http://www.opensource-socialnetwork.org/licence */ function ossn_themes_init() { ossn_register_plugins_by_path(ossn_default_theme() . 'plugins/'); }
/** * Get user profile photo * * @return mixed data; */ function get_profile_photo($guid, $size) { $photo = new OssnFile(); $photo->owner_guid = $guid; if (isset($size) && array_key_exists($size, ossn_user_image_sizes())) { $isize = "{$size}_"; } $photo->type = 'user'; $photo->subtype = 'profile:photo'; $photos = $photo->getFiles(); if (isset($photos->{0}->value) && !empty($photos->{0}->value)) { $datadir = ossn_get_userdata("user/{$guid}/{$photos->{0}->value}"); if (!empty($size)) { $image = str_replace('profile/photo/', '', $photos->{0}->value); $datadir = ossn_get_userdata("user/{$guid}/profile/photo/{$isize}{$image}"); } return file_get_contents($datadir); } else { $datadir = ossn_default_theme() . "images/nopictures/users/{$size}.jpg"; return file_get_contents($datadir); } return false; }