/** * Modern profile * * @access private * @return void [Outputs to screen] */ private function _viewModern() { //----------------------------------------- // INIT //----------------------------------------- $member_id = intval($this->request['id']) ? intval($this->request['id']) : intval($this->request['MID']); $member_id = $member_id ? $member_id : $this->memberData['member_id']; $tab = substr(IPSText::alphanumericalClean(str_replace('..', '', trim($this->request['tab']))), 0, 20); $firsttab = ''; $member = array(); $comments = array(); $comments_html = ""; $friends = array(); $visitors = array(); $comment_perpage = 5; $pips = 0; $tabs = array(); $_tabs = array(); $_positions = array(0 => 0); $custom_path = IPSLib::getAppDir('members') . '/sources/tabs'; $_member_ids = array(); $sql_extra = ''; $pass = 0; $mod = 0; $_todays_date = getdate(); $time_adjust = $this->settings['time_adjust'] == "" ? 0 : $this->settings['time_adjust']; $board_posts = $this->caches['stats']['total_topics'] + $this->caches['stats']['total_replies']; //----------------------------------------- // Check input.. //----------------------------------------- if (!$member_id) { $this->registry->output->silentRedirect($this->settings['base_url']); } //----------------------------------------- // Configure tabs //----------------------------------------- if (is_dir($custom_path)) { foreach (new DirectoryIterator($custom_path) as $f) { if (!$f->isDot() && !$f->isDir()) { $file = $f->getFileName(); if ($file[0] == '.') { continue; } if (preg_match("#\\.conf\\.php\$#i", $file)) { $classname = str_replace(".conf.php", "", $file); require $custom_path . '/' . $file; //------------------------------- // Allowed to use? //------------------------------- if ($CONFIG['plugin_enabled']) { if (in_array($this->settings['search_method'], array('traditional', 'sphinx')) && $CONFIG['plugin_key'] == 'recentActivity') { continue; } $_position = in_array($CONFIG['plugin_order'], $_positions) ? count($_positions) + 1 : $CONFIG['plugin_order']; $_tabs[$_position] = $CONFIG; $_positions[$_position] = $_position; } } } } } ksort($_tabs); foreach ($_tabs as $_pos => $data) { if (!$firsttab) { $firsttab = $data['plugin_key']; } $data['_lang'] = isset($this->lang->words[$data['plugin_lang_bit']]) ? $this->lang->words[$data['plugin_lang_bit']] : $data['plugin_name']; $tabs[$data['plugin_key']] = $data; } if ($tab != 'comments' and $tab != 'settings' and !file_exists($custom_path . '/' . $tab . '.php')) { $tab = $firsttab; } //----------------------------------------- // Grab all data... //----------------------------------------- $member = IPSMember::load($member_id, 'profile_portal,pfields_content,sessions,groups', 'id'); if (!$member['member_id']) { $this->registry->output->showError('profiles_no_member', 10246); } /* Check USER permalink... */ $this->registry->getClass('output')->checkPermalink($member['members_seo_name'] ? $member['members_seo_name'] : IPSText::makeSeoTitle($member['members_display_name'])); /* Build data */ $member = IPSMember::buildDisplayData($member, array('customFields' => 1, 'cfSkinGroup' => 'profile', 'checkFormat' => 1, 'cfGetGroupData' => 1, 'signature' => 1)); //----------------------------------------- // Recent visitor? //----------------------------------------- if ($member['member_id'] != $this->memberData['member_id']) { list($be_anon, $loggedin) = explode('&', $this->memberData['login_anonymous']); if (!$be_anon) { $this->_addRecentVisitor($member, $this->memberData['member_id']); } } //----------------------------------------- // DST? //----------------------------------------- if ($member['dst_in_use'] == 1) { $member['time_offset'] += 1; } //----------------------------------------- // Format extra user data //----------------------------------------- $member['_age'] = $member['bday_year'] ? date('Y') - $member['bday_year'] : 0; if ($member['bday_month'] > date('n')) { $member['_age'] -= 1; } else { if ($member['bday_month'] == date('n')) { if ($member['bday_day'] > date('j')) { $member['_age'] -= 1; } } } $member['_local_time'] = $member['time_offset'] != "" ? gmstrftime($this->settings['clock_long'], time() + $member['time_offset'] * 3600 + $time_adjust * 60) : ''; $member['g_title'] = IPSLib::makeNameFormatted($member['g_title'], $member['g_id'], $member['prefix'], $member['suffix']); $member['_posts_day'] = 0; $member['_total_pct'] = 0; $member['_bday_month'] = $member['bday_month'] ? $this->lang->words['M_' . $member['bday_month']] : 0; //----------------------------------------- // BIO //----------------------------------------- $member['pp_bio_content'] = IPSText::getTextClass('bbcode')->stripBadWords($member['pp_bio_content']); $member['pp_bio_content'] = IPSText::wordwrap($member['pp_bio_content'], '25', ' '); if (!$this->settings['disable_profile_stats']) { $posts = $this->DB->buildAndFetch(array('select' => "COUNT(*) as total_posts", 'from' => "posts", 'where' => "author_id=" . $member['member_id'])); $member['posts'] = $posts['total_posts']; //----------------------------------------- // Total posts //----------------------------------------- if ($member['posts'] and $board_posts) { $member['_posts_day'] = round($member['posts'] / ((time() - $member['joined']) / 86400), 2); # Fix the issue when there is less than one day $member['_posts_day'] = $member['_posts_day'] > $member['posts'] ? $member['posts'] : $member['_posts_day']; $member['_total_pct'] = sprintf('%.2f', $member['posts'] / $board_posts * 100); } $member['_posts_day'] = floatval($member['_posts_day']); //----------------------------------------- // Most active in //----------------------------------------- $favorite = $this->DB->buildAndFetch(array('select' => 'COUNT(p.author_id) as f_posts', 'from' => array('posts' => 'p'), 'where' => 'p.author_id=' . $member['member_id'] . ' AND ' . $this->registry->permissions->buildPermQuery('i'), 'order' => 'f_posts DESC', 'group' => 't.forum_id', 'add_join' => array(array('select' => 't.forum_id', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id'), array('from' => array('permission_index' => 'i'), 'where' => "i.perm_type='forum' AND i.perm_type_id=t.forum_id")))); $member['favorite_id'] = $favorite['forum_id']; $member['_fav_posts'] = $favorite['f_posts']; if ($member['posts']) { $member['_fav_percent'] = round($favorite['f_posts'] / $member['posts'] * 100); } } //----------------------------------------- // Comments //----------------------------------------- if ($member['pp_setting_count_comments']) { require_once IPSLib::getAppDir('members') . '/sources/comments.php'; $comment_lib = new profileCommentsLib($this->registry); $comment_html = $comment_lib->buildComments($member); } //----------------------------------------- // Visitors //----------------------------------------- if ($member['pp_setting_count_visitors']) { $_pp_last_visitors = unserialize($member['pp_last_visitors']); $_visitor_info = array(); $_count = 1; if (is_array($_pp_last_visitors)) { krsort($_pp_last_visitors); $_members = IPSMember::load(array_values($_pp_last_visitors), 'extendedProfile'); foreach ($_members as $_id => $_member) { $_visitor_info[$_id] = IPSMember::buildDisplayData($_member, 0); } foreach ($_pp_last_visitors as $_time => $_id) { if ($_count > $member['pp_setting_count_visitors']) { break; } $_count++; if (!$_visitor_info[$_id]['members_display_name_short']) { $_visitor_info[$_id] = IPSMember::setUpGuest(); } $_visitor_info[$_id]['_visited_date'] = ipsRegistry::getClass('class_localization')->getDate($_time, 'TINY'); $_visitor_info[$_id]['members_display_name_short'] = $_visitor_info[$_id]['members_display_name_short'] ? $_visitor_info[$_id]['members_display_name_short'] : $this->lang->words['global_guestname']; $visitors[] = $_visitor_info[$_id]; } } } //----------------------------------------- // Friends //----------------------------------------- # Get random number from member's friend cache... grab 10 random. array_rand( array, no.) # also fall back on last 10 if no cache if ($member['pp_setting_count_friends'] > 0 && $this->settings['friends_enabled']) { $member['_cache'] = IPSMember::unpackMemberCache($member['members_cache']); if (is_array($member['_cache']['friends']) and count($member['_cache']['friends'])) { foreach ($member['_cache']['friends'] as $id => $approved) { $id = intval($id); if ($approved and $id) { $_member_ids[] = $id; } } $member['_total_approved_friends'] = count($_member_ids); if (is_array($_member_ids) and count($_member_ids)) { $_max = count($_member_ids) > 50 ? 50 : count($_member_ids); $_rand = array_rand($_member_ids, $_max); $_final = array(); # If viewing member is in list, let's show em if (in_array($this->memberData['member_id'], $_member_ids)) { $_final[] = $this->memberData['member_id']; $new_mids = array(); foreach ($_member_ids as $mid) { if ($mid == $this->memberData['member_id']) { continue; } $new_mids[] = $mid; } $_member_ids = $new_mids; unset($new_mids); if (is_array($_rand)) { if (count($_rand) >= 50) { array_pop($_rand); } } } if (is_array($_rand) and count($_rand)) { foreach ($_rand as $_id) { $_final[] = $_member_ids[$_id]; } } if (count($_final)) { $sql_extra = ' AND pf.friends_friend_id IN (' . IPSText::cleanPermString(implode(',', $_final)) . ')'; } } } $this->DB->build(array('select' => 'pf.*', 'from' => array('profile_friends' => 'pf'), 'where' => 'pf.friends_member_id=' . $member_id . ' AND pf.friends_approved=1' . $sql_extra, 'limit' => array(0, 50), 'order' => 'm.members_display_name ASC', 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=pf.friends_friend_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(); while ($row = $this->DB->fetch($outer)) { $row['_friends_added'] = ipsRegistry::getClass('class_localization')->getDate($row['friends_added'], 'SHORT'); $row['_location'] = $row['location'] ? $row['location'] : $this->lang->words['no_info']; $row = IPSMember::buildProfilePhoto($row); $row['members_display_name_short'] = IPSText::truncate($row['members_display_name'], 13); $friends[] = $row; } } $member['_total_displayed_friends'] = count($friends); //----------------------------------------- // Online location //----------------------------------------- $member = IPSMember::getLocation($member); //----------------------------------------- // Add profile view //----------------------------------------- $this->DB->insert('profile_portal_views', array('views_member_id' => $member['member_id']), true); //----------------------------------------- // Grab default tab... //----------------------------------------- $tab_html = ''; if ($tab != 'comments' and $tab != 'settings') { if (file_exists($custom_path . '/' . $tab . '.php')) { require $custom_path . '/pluginParentClass.php'; require $custom_path . '/' . $tab . '.php'; $_func_name = 'profile_' . $tab; $plugin = new $_func_name($this->registry); $tab_html = $plugin->return_html_block($member); } } //----------------------------------------- // Set description tag //----------------------------------------- $_desc = $member['pp_about_me'] ? $member['pp_about_me'] : $member['signature']; if ($_desc) { $this->registry->output->addMetaTag('description', $member['members_display_name'] . ': ' . IPSText::getTextClass('bbcode')->stripAllTags($_desc)); } //----------------------------------------- // Add to output //----------------------------------------- $this->member_name = $member['members_display_name']; $this->output = $this->registry->getClass('output')->getTemplate('profile')->profileModern($tabs, $member, $comment_html, $friends, $visitors, $tab, $tab_html, $fields); }
/** * Loads the content for the comments tab * * @access private * @return void [Prints to screen] * @since IPB 2.2.0.2006-08-02 */ private function _viewComments() { //----------------------------------------- // INIT //----------------------------------------- $member_id = intval($this->request['member_id']); $md5check = IPSText::md5Clean($this->request['md5check']); $content = ''; $comment_perpage = 10; $pages = ''; $start = intval($this->request['st']); $sql_extra = ''; //----------------------------------------- // MD5 check //----------------------------------------- if ($md5check != $this->member->form_hash) { die(''); } //----------------------------------------- // Not my tab? So no moderation... //----------------------------------------- if ($member_id != $this->memberData['member_id'] and !$this->memberData['g_is_supmod']) { $sql_extra = ' AND comment_approved=1'; } //----------------------------------------- // Load member //----------------------------------------- $member = IPSMember::load($member_id); //----------------------------------------- // Check //----------------------------------------- if (!$member['member_id']) { die(''); } //----------------------------------------- // How many comments must a man write down // before he is considered a spammer? //----------------------------------------- $comment_count = $this->DB->buildAndFetch(array('select' => 'count(*) as count_comment', 'from' => 'profile_comments', 'where' => 'comment_for_member_id=' . $member_id . $sql_extra)); //----------------------------------------- // Pages //----------------------------------------- $pages = $this->registry->output->generatePagination(array('totalItems' => intval($comment_count['count_comment']), 'itemsPerPage' => $comment_perpage, 'currentStartValue' => $start, 'baseUrl' => $this->settings['base_url'] . 'app=members&section=comments&module=profile&member_id=' . $member_id . '&do=view&md5check=' . $this->member->form_hash)); //----------------------------------------- // Regenerate comments... //----------------------------------------- $this->DB->build(array('select' => 'pc.*', 'from' => array('profile_comments' => 'pc'), 'where' => 'pc.comment_for_member_id=' . $member_id . $sql_extra, 'order' => 'pc.comment_date DESC', 'limit' => array($start, $comment_perpage), 'add_join' => array(0 => array('select' => 'm.members_display_name, m.login_anonymous', 'from' => array('members' => 'm'), 'where' => 'm.member_id=pc.comment_by_member_id', 'type' => 'left'), 1 => array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left')))); $o = $this->DB->execute(); while ($row = $this->DB->fetch($o)) { $row['comment_content'] = IPSText::wordwrap($row['comment_content'], '19', ' '); $row = IPSMember::buildDisplayData($row, 0); if (!$row['members_display_name_short']) { $row = array_merge($row, IPSMember::setUpGuest()); } $comments[] = $row; } //----------------------------------------- // Ok.. show the settings //----------------------------------------- $content = $this->registry->getClass('output')->getTemplate('profile')->showIframeComments($member, $comments, $pages); $this->registry->getClass('output')->setTitle($this->settings['board_name']); $this->registry->getClass('output')->popUpWindow($content); }