/**
  * Returns content for the page.
  *
  * @access	public
  * @author	Matt Mecham
  * @param    array 				Member data
  * @return   array 				Array of tabs, content
  */
 public function getDisplayContent($member = array())
 {
     //-----------------------------------------
     // Load skin
     //-----------------------------------------
     $this->html = ipsRegistry::getClass('output')->loadTemplate('cp_skin_member_form', 'forums');
     //-----------------------------------------
     // Load lang
     //-----------------------------------------
     ipsRegistry::getClass('class_localization')->loadLanguageFile(array('admin_forums'), 'forums');
     ipsRegistry::getClass('class_localization')->loadLanguageFile(array('admin_member_form'), 'forums');
     //-----------------------------------------
     // Get member data
     //-----------------------------------------
     $member = IPSMember::load($member['member_id'], 'extendedProfile');
     $member['_avatar'] = str_replace('<img ', '<img id="MF__avatar" ', IPSMember::buildAvatar($member));
     //-----------------------------------------
     // Show...
     //-----------------------------------------
     return array('tabs' => $this->html->acp_member_form_tabs($member), 'content' => $this->html->acp_member_form_main($member));
 }
 /**
  * Show the "news" articles
  *
  * @access	public
  * @return	string		HTML content to replace tag with
  */
 public function recent_topics_last_x()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $attach_pids = array();
     $attach_posts = array();
     $forums = array();
     $rows = array();
     $output = array();
     $where_clause = array();
     $limit = $this->settings['recent_topics_article_max'] ? $this->settings['recent_topics_article_max'] : 5;
     $posts = intval($this->memberData['posts']);
     //-----------------------------------------
     // Grab articles new/recent in 1 bad ass query
     //-----------------------------------------
     foreach (explode(',', $this->settings['recent_topics_article_forum']) as $forum_id) {
         if (!$forum_id) {
             continue;
         }
         $forums[] = intval($forum_id);
     }
     if (!count($forums)) {
         return;
     }
     /* Loop through the forums and build a list of forums we're allowed access to */
     $forumIdsOk = array();
     foreach ($this->registry->class_forums->forum_by_id as $id => $data) {
         /* Allowing this forum? */
         if (!in_array($id, $forums, $id)) {
             continue;
         }
         /* Can we read? */
         if (!$this->registry->permissions->check('read', $data)) {
             continue;
         }
         /* Can read, but is it password protected, etc? */
         if (!$this->registry->class_forums->forumsCheckAccess($id, 0, 'forum', array(), true)) {
             continue;
         }
         if (!$data['can_view_others']) {
             continue;
         }
         if ($data['min_posts_view'] > $posts) {
             continue;
         }
         $forumIdsOk[] = $id;
     }
     if (!count($forumIdsOk)) {
         return '';
     }
     /* Add allowed forums */
     $where_clause[] = "t.forum_id IN (" . implode(",", $forumIdsOk) . ")";
     //-----------------------------------------
     // Will we need to parse attachments?
     //-----------------------------------------
     $parseAttachments = false;
     //-----------------------------------------
     // Run query
     //-----------------------------------------
     $pinned = array();
     $unpinned = array();
     $all = array();
     $data = array();
     $count = 0;
     if (!$this->settings['portal_exclude_pinned']) {
         /* Fetch all pinned topics to avoid filesort */
         $this->DB->build(array('select' => 't.tid, t.start_date', 'from' => 'topics t', 'where' => "t.pinned=1 AND t.approved=1 AND t.state != 'link'" . (count($where_clause) ? ' AND ' . implode(' AND ', $where_clause) : ''), 'limit' => array($limit)));
         $this->DB->execute();
         while ($row = $this->DB->fetch()) {
             $pinned[$row['start_date']] = $row['tid'];
             $all[$row['start_date']] = $row['tid'];
         }
     }
     /* Still need more? */
     if (count($pinned) < $limit) {
         $pinnedWhere = $this->settings['portal_exclude_pinned'] ? "" : "t.pinned=0 AND ";
         $this->DB->build(array('select' => 't.tid, t.start_date', 'from' => 'topics t', 'where' => $pinnedWhere . "t.approved=1 AND t.state != 'link'" . (count($where_clause) ? ' AND ' . implode(' AND ', $where_clause) : ''), 'order' => 'tid DESC', 'limit' => array($limit - count($pinned))));
         $this->DB->execute();
         while ($row = $this->DB->fetch()) {
             $unpinned[$row['start_date']] = $row['tid'];
             $all[$row['start_date']] = $row['tid'];
         }
     }
     /* got anything? */
     if (!count($all)) {
         return;
     }
     $this->DB->build(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => "t.tid IN (" . implode(",", array_values($all)) . ")", 'add_join' => array(array('select' => 'p.*', 'from' => array('posts' => 'p'), 'where' => 'p.pid=t.topic_firstpost', 'type' => 'left'), array('select' => 'f.use_html', 'from' => array('forums' => 'f'), 'where' => "f.id=t.forum_id", 'type' => 'left'), array('select' => 'm.member_id, m.members_display_name, m.member_group_id, m.members_seo_name, m.mgroup_others, m.login_anonymous, m.last_visit, m.last_activity', 'from' => array('members' => 'm'), 'where' => 'm.member_id=p.author_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'))));
     $outer = $this->DB->execute();
     //-----------------------------------------
     // Loop through..
     //-----------------------------------------
     while ($row = $this->DB->fetch($outer)) {
         $data[$row['tid']] = $row;
     }
     krsort($unpinned);
     krsort($pinned);
     foreach ($unpinned as $date => $tid) {
         if (count($pinned) < $limit) {
             $pinned[$date] = $tid;
         } else {
             break;
         }
         $count++;
     }
     /* Now put it altogether */
     foreach ($pinned as $date => $tid) {
         //-----------------------------------------
         // INIT
         //-----------------------------------------
         $entry = $data[$tid];
         $bottom_string = "";
         $read_more = "";
         $top_string = "";
         $got_these_attach = 0;
         if ($entry['topic_hasattach']) {
             $parseAttachments = true;
         }
         //-----------------------------------------
         // Parse the post
         //-----------------------------------------
         IPSText::getTextClass('bbcode')->parse_smilies = $entry['use_emo'];
         IPSText::getTextClass('bbcode')->parse_html = ($entry['use_html'] and $entry['post_htmlstate']) ? 1 : 0;
         IPSText::getTextClass('bbcode')->parse_nl2br = $entry['post_htmlstate'] == 2 ? 1 : 0;
         IPSText::getTextClass('bbcode')->parse_bbcode = 1;
         IPSText::getTextClass('bbcode')->parsing_section = 'topics';
         IPSText::getTextClass('bbcode')->parsing_mgroup = $entry['member_group_id'];
         IPSText::getTextClass('bbcode')->parsing_mgroup_others = $entry['mgroup_others'];
         $entry['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($entry['post']);
         //-----------------------------------------
         // BASIC INFO
         //-----------------------------------------
         $real_posts = $entry['posts'];
         $entry['posts'] = ipsRegistry::getClass('class_localization')->formatNumber(intval($entry['posts']));
         if (!$entry['author_id']) {
             $entry['members_display_name'] = $this->settings['guest_name_pre'] . $entry['author_name'] . $this->settings['guest_name_suf'];
             $entry['member_id'] = 0;
         } else {
             $entry = IPSMember::buildDisplayData($entry);
         }
         //-----------------------------------------
         // Get Date
         //-----------------------------------------
         $entry['date'] = $this->registry->class_localization->getDate($entry['post_date'], "manual{" . $this->settings['csite_article_date'] . "}");
         //-----------------------------------------
         // Attachments?
         //-----------------------------------------
         if ($entry['pid']) {
             $attach_pids[$entry['pid']] = $entry['pid'];
         }
         //-----------------------------------------
         // Avatar
         //-----------------------------------------
         $entry['avatar'] = IPSMember::buildAvatar($entry);
         if (IPSMember::checkPermissions('download', $entry['forum_id']) === FALSE) {
             $this->settings['show_img_upload'] = 0;
         }
         //-----------------------------------------
         // View image...
         //-----------------------------------------
         $entry['post'] = IPSText::getTextClass('bbcode')->memberViewImages($entry['post']);
         $rows[] = $entry;
     }
     $output = $this->registry->getClass('output')->getTemplate('portal')->articles($rows);
     //-----------------------------------------
     // Process Attachments
     //-----------------------------------------
     if ($parseAttachments and count($attach_pids)) {
         if (!is_object($this->class_attach)) {
             //-----------------------------------------
             // Grab render attach class
             //-----------------------------------------
             require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php';
             $this->class_attach = new class_attach($this->registry);
             $this->class_attach->attach_post_key = '';
             ipsRegistry::getClass('class_localization')->loadLanguageFile(array('public_topic'), 'forums');
         }
         $this->class_attach->attach_post_key = '';
         $this->class_attach->type = 'post';
         $this->class_attach->init();
         $output = $this->class_attach->renderAttachments($output, $attach_pids);
         $output = $output[0]['html'];
     }
     return $output;
 }
 /**
  * Show the avatar page
  *
  * @access	public
  * @author	Matt Mecham
  * @return	string		Processed HTML
  */
 public function formAvatar()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $member = IPSMember::load($this->memberData['member_id'], 'extendedProfile,customFields,groups');
     //-----------------------------------------
     // Check to make sure that we can edit profiles..
     //-----------------------------------------
     if (!$member['g_edit_profile']) {
         $this->registry->getClass('output')->showError('members_profile_disabled', 1021);
     }
     if (!$this->settings['avatars_on']) {
         $this->registry->getClass('output')->showError('members_profile_disabled', 1030);
     }
     //-----------------------------------------
     // Organise the dimensions
     //-----------------------------------------
     if (strpos($this->memberData['avatar_size'], "x")) {
         list($this->settings['currentWidth'], $this->settings['currentHeight']) = explode("x", strtolower($member['avatar_size']));
     }
     list($this->settings['maxWidth'], $this->settings['maxHeight']) = explode("x", strtolower($this->settings['avatar_dims']));
     list($w, $h) = explode("x", strtolower($this->settings['avatar_def']));
     //-----------------------------------------
     // Get the avatar gallery
     //-----------------------------------------
     $av_categories = array_merge(array(0 => array(0, '&lt; ' . $this->lang->words['av_root'] . ' &gt;')), IPSMember::getFunction()->getHostedAvatarCategories());
     //-----------------------------------------
     // Get the avatar gallery selected
     //-----------------------------------------
     $url_avatar = "http://";
     $avatar_type = "na";
     if ($member['avatar_location'] != "" and $member['avatar_location'] != "noavatar") {
         if (!$member['avatar_type']) {
             if (preg_match("/^upload:/", $member['avatar'])) {
                 $avatar_type = "upload";
             } else {
                 if (!preg_match("/^http/i", $member['avatar'])) {
                     $avatar_type = "local";
                 } else {
                     $url_avatar = $member['avatar'];
                     $avatar_type = "url";
                 }
             }
         } else {
             switch ($member['avatar_type']) {
                 case 'upload':
                     $avatar_type = 'upload';
                     break;
                 case 'url':
                     $avatar_type = 'url';
                     $url_avatar = $member['avatar_location'];
                     break;
                 case 'gravatar':
                     $avatar_type = 'gravatar';
                     break;
                 default:
                     $avatar_type = 'local';
                     break;
             }
         }
     }
     //-----------------------------------------
     // Rest of the form..
     //-----------------------------------------
     if ($member['g_avatar_upload'] == 1) {
         $this->uploadFormMax = 9000000;
     }
     //-----------------------------------------
     // Force a form action?
     //-----------------------------------------
     $is_reset = 0;
     if ($this->settings['upload_domain']) {
         $is_reset = 1;
         $original = $this->settings['base_url'];
         if ($this->member->session_type == 'cookie') {
             $this->settings['base_url'] = $this->settings['upload_domain'] . '/index.' . $this->settings['php_ext'] . '?';
         } else {
             $this->settings['base_url'] = $this->settings['upload_domain'] . '/index.' . $this->settings['php_ext'] . '?s=' . $this->member->session_id . '&amp;';
         }
     }
     //-----------------------------------------
     // If yes, show little thingy at top
     //-----------------------------------------
     $this->lang->words['av_allowed_files'] = sprintf($this->lang->words['av_allowed_files'], implode(' .', explode("|", $this->settings['avatar_ext'])));
     $return = $this->registry->getClass('output')->getTemplate('ucp')->memberAvatarForm(array('member' => $member, 'avatar_categories' => $av_categories, 'current_url_avatar' => $url_avatar, 'current_avatar_image' => IPSMember::buildAvatar($member, 0, 1), 'current_avatar_type' => $this->lang->words['av_t_' . $avatar_type], 'current_avatar_dims' => $avatar_type != 'gravatar' ? $member['avatar_size'] == "x" ? "" : $member['avatar_size'] : ''));
     //-----------------------------------------
     // Reset forced form action?
     //-----------------------------------------
     if ($is_reset) {
         $this->settings['base_url'] = $original;
     }
     return $return;
 }
 /**
  * @desc			Returns the HTML code to show a member's avatar.
  * @param	int		$userID User ID. If $userID is ommited, the last known member id is used.
  * @return	string	HTML Code for member's avatar, or false on failure
  * @author			Matthias Reuter
  * @sample
  * <code>
  * $ipbwi->member->avatar(5);
  * </code>
  * @since			2.0
  */
 public function avatar($userID = false)
 {
     // No Member ID specified? Go for the current users UID.
     $member = $this->info($userID);
     $avatar = IPSMember::buildAvatar($member);
     #$avatar = str_replace('http://www.gravatar.com/avatar/f4b24f6f1dad5d1dfb39dcb281897203?d=http%3A%2F%2Froot.pc-intern.com%2Fdevelopment%2Fprojects.pc-intern.com%2Fpublic%2Fstyle_avatars%2Fblank_avatar.gif','http://root.pc-intern.com/development/projects.pc-intern.com/public/style_images/master/profile/default_thumb.png',$avatar);
     return $avatar;
 }
 * @subpackage	Members
 * @link		http://www.
 * @version		$Rev$
 *
 */
//-----------------------------------------
// Get stuff we need
//-----------------------------------------
define('IPB_THIS_SCRIPT', 'api');
define('IPB_LOAD_SQL', 'queries');
require_once '../../initdata.php';
require_once IPS_ROOT_PATH . 'sources/base/ipsRegistry.php';
$registry = ipsRegistry::instance();
$registry->init();
$id = intval(ipsRegistry::$request['id']);
$member = IPSMember::load($id);
$avatar = IPSMember::buildAvatar($member);
//-----------------------------------------
// Print avatar
//-----------------------------------------
print <<<HTML
<!DOCTYPE html 
\t     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
\t     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\t<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
\t<head>
\t</head>
\t<body>{$avatar}</body>
\t</html>
HTML;
exit;