/**
  * Class entry point
  *
  * @access	public
  * @param	object		Registry reference
  * @return	void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     $this->registry->class_localization->loadLanguageFile(array('public_profile'));
     /* INIT */
     $member_id = intval($this->request['mid']);
     //-----------------------------------------
     // Can we access?
     //-----------------------------------------
     if (!$this->memberData['g_mem_info']) {
         $this->returnString('error');
     }
     if (!$member_id) {
         $this->returnString('error');
     }
     $member = IPSMember::load($member_id, 'profile_portal,pfields_content,sessions,groups,basic', 'id');
     if (!$member['member_id']) {
         $this->returnString('error');
     }
     $this->registry->class_localization->loadLanguageFile(array('public_online'), 'members');
     $member = IPSMember::buildDisplayData($member, array('customFields' => 1, 'cfSkinGroup' => 'profile'));
     $member = IPSMember::getLocation($member);
     $board_posts = $this->caches['stats']['total_topics'] + $this->caches['stats']['total_replies'];
     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']);
     $this->returnHtml($this->registry->getClass('output')->getTemplate('profile')->showCard($member));
 }
Beispiel #2
0
 /**
  * Class entry point
  *
  * @param	object		Registry reference
  * @return	@e void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // Can we access?
     //-----------------------------------------
     if (!$this->memberData['g_mem_info']) {
         $this->returnString('error');
     }
     $this->registry->class_localization->loadLanguageFile(array('public_profile', 'public_online'), 'members');
     /* Got a valid member? */
     $member_id = intval($this->request['mid']);
     if (empty($member_id)) {
         $this->returnString('error');
     }
     $member = IPSMember::load($member_id, 'profile_portal,pfields_content,sessions,groups,basic', 'id');
     if (empty($member['member_id'])) {
         $this->returnString('error');
     }
     $member = IPSMember::buildDisplayData($member, array('customFields' => 1, 'cfSkinGroup' => 'profile', 'spamStatus' => 1));
     $member = IPSMember::getLocation($member);
     $board_posts = $this->caches['stats']['total_topics'] + $this->caches['stats']['total_replies'];
     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']);
     /* Load status class */
     if (!$this->registry->isClassLoaded('memberStatus')) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/member/status.php', 'memberStatus');
         $this->registry->setClass('memberStatus', new $classToLoad(ipsRegistry::instance()));
     }
     /* Fetch */
     $member['_status'] = $this->registry->getClass('memberStatus')->fetch($this->memberData, array('member_id' => $member['member_id'], 'limit' => 1));
     if (is_array($member['_status']) and count($member['_status'])) {
         $member['_status'] = array_pop($member['_status']);
     }
     /* Reputation */
     if ($this->settings['reputation_protected_groups']) {
         if (in_array($member['member_group_id'], explode(",", $this->settings['reputation_protected_groups']))) {
             $this->settings['reputation_show_profile'] = false;
         }
     }
     $this->returnHtml($this->registry->getClass('output')->getTemplate('profile')->showCard($member));
 }
 /**
  * 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);
 }
Beispiel #4
0
 /**
  * Modern profile
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _viewModern()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $member_id = intval($this->request['id']) ? intval($this->request['id']) : intval($this->request['MID']);
     if (!$member_id) {
         $this->registry->output->showError('profiles_no_member', 10246.0, null, null, 404);
     }
     //-----------------------------------------
     // Grab all data...
     //-----------------------------------------
     $member = IPSMember::load($member_id, 'profile_portal,pfields_content,sessions,groups', 'id');
     //-----------------------------------------
     // Can we access?
     //-----------------------------------------
     if (!$this->memberData['g_mem_info'] && $this->memberData['member_id'] != $member['member_id']) {
         $this->registry->output->showError('profiles_off', 10245, null, null, 403);
     }
     $tab = substr(IPSText::alphanumericalClean(str_replace('..', '', trim($this->request['tab']))), 0, 20);
     $firsttab = '';
     $friends = array();
     $visitors = array();
     $comment_perpage = 5;
     $pips = 0;
     $default_tab = '';
     $tabs = array();
     $_tabs = array();
     $_positions = array(0 => 0);
     $_member_ids = array();
     $sql_extra = '';
     $pass = 0;
     $mod = 0;
     $_todays_date = getdate();
     $_rCustom = intval($this->request['removeCustomization']);
     $_dCustom = intval($this->request['disableCustomization']);
     $time_adjust = $this->settings['time_adjust'] == "" ? 0 : $this->settings['time_adjust'];
     $board_posts = $this->caches['stats']['total_topics'] + $this->caches['stats']['total_replies'];
     $seenFiles = array();
     /* Removing customization? */
     if ($_rCustom and ($member_id == $this->memberData['member_id'] or $this->memberData['g_access_cp'] or $this->memberData['g_is_supmod'] and !$member['g_access_cp']) and $this->request['secure_key'] == $this->member->form_hash) {
         IPSMember::save($member_id, array('extendedProfile' => array('pp_customization' => serialize(array()))));
     } else {
         if ($_rCustom) {
             $this->registry->output->showError('profile_no_remove_perm', '10246.-1', null, null, 403);
         }
     }
     /* Disable? */
     if ($_dCustom and ($this->memberData['g_access_cp'] or $this->memberData['g_is_supmod'] and !$member['g_access_cp']) and $this->request['secure_key'] == $this->member->form_hash) {
         IPSMember::save($member_id, array('core' => array('bw_disable_customization' => 1)));
     } else {
         if ($_dCustom) {
             $this->registry->output->showError('profile_no_remove_perm', '10246.-1', null, null, 403);
         }
     }
     if (!$member['member_id']) {
         $this->registry->output->showError('profiles_no_member', 10246, null, null, 404);
     }
     /* Member banned or is spammer? */
     if (IPSMember::isInactive($member) && !$this->memberData['g_is_supmod']) {
         $this->registry->output->showError('profiles_not_active', '10246.1', null, null, 403);
     }
     //-----------------------------------------
     // Configure tabs
     //-----------------------------------------
     foreach (IPSLib::getEnabledApplications() as $appDir => $app) {
         /* Path to tabs */
         $custom_path = IPSLib::getAppDir($appDir) . '/extensions/profileTabs';
         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);
                         /* Block the old about me file */
                         if ($classname == 'aboutme') {
                             continue;
                         }
                         $CONFIG = array();
                         require $custom_path . '/' . $file;
                         /*noLibHook*/
                         //-------------------------------
                         // Allowed to use?
                         //-------------------------------
                         if ($CONFIG['plugin_enabled']) {
                             /* Block friends tab if we have disabled friends or friends feature is shut off */
                             if ($CONFIG['plugin_key'] == 'friends' and (!$member['pp_setting_count_friends'] or !$this->settings['friends_enabled'])) {
                                 continue;
                             }
                             $CONFIG['app'] = $appDir;
                             $_position = $this->_getTabPosition($_positions, $CONFIG['plugin_order']);
                             $_tabs[$_position] = $CONFIG;
                             $_positions[] = $_position;
                         }
                     }
                 }
             }
         }
     }
     ksort($_tabs);
     foreach ($_tabs as $_pos => $data) {
         $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 && @is_file(IPSLib::getAppDir($tabs[$tab]['app']) . '/extensions/profileTabs/' . $tab . '.php')) {
         $default_tab = $tabs[$tab]['app'] . ':' . $tab;
         /* Update <title> */
         $this->lang->words['page_title_pp'] .= ': ' . $tabs[$tab]['_lang'];
     } else {
         $default_tab = 'core:info';
     }
     $friends = $this->_getRandomFriends($member);
     /* 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, 'spamStatus' => 1));
     //-----------------------------------------
     // Recent visitor?
     //-----------------------------------------
     if ($member['member_id'] != $this->memberData['member_id'] && !IPSMember::isLoggedInAnon($this->memberData)) {
         $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'] = IPSMember::makeNameFormatted($member['g_title'], $member['g_id'], $member['prefix'], $member['suffix']);
     $member['_bday_month'] = $member['bday_month'] ? $this->lang->words['M_' . $member['bday_month']] : 0;
     //-----------------------------------------
     // Visitors
     //-----------------------------------------
     if ($member['pp_setting_count_visitors']) {
         $_pp_last_visitors = unserialize($member['pp_last_visitors']);
         $_visitor_info = array();
         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, array('reputation' => 0, 'warn' => 0));
             }
             foreach ($_pp_last_visitors as $_time => $_id) {
                 if (!$_visitor_info[$_id]['members_display_name_short']) {
                     $_visitor_info[$_id] = IPSMember::buildDisplayData(IPSMember::setUpGuest(), array('reputation' => 0, 'warn' => 0));
                 }
                 $_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];
                 if (count($visitors) == 5) {
                     break;
                 }
             }
         }
     }
     //-----------------------------------------
     // 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) {
         if (@is_file(IPSLib::getAppDir($tabs[$tab]['app']) . '/extensions/profileTabs/' . $tab . '.php')) {
             require IPSLib::getAppDir('members') . '/sources/tabs/pluginParentClass.php';
             /*noLibHook*/
             $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir($tabs[$tab]['app']) . '/extensions/profileTabs/' . $tab . '.php', 'profile_' . $tab, $tabs[$tab]['app']);
             $plugin = new $classToLoad($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::xssMakeJavascriptSafe(IPSText::getTextClass('bbcode')->stripAllTags($_desc)));
     }
     /* Reputation */
     if ($this->settings['reputation_protected_groups']) {
         if (in_array($member['member_group_id'], explode(",", $this->settings['reputation_protected_groups']))) {
             $this->settings['reputation_show_profile'] = false;
         }
     }
     //-----------------------------------------
     // Try to "fix" empty custom field groups
     //-----------------------------------------
     foreach ($member['custom_fields'] as $group => $mdata) {
         if ($group != 'profile_info' and $group != 'contact') {
             if (is_array($member['custom_fields'][$group]) and count($member['custom_fields'][$group])) {
                 $_count = 0;
                 foreach ($member['custom_fields'][$group] as $key => $value) {
                     if ($value) {
                         $_count++;
                     }
                 }
                 if (!$_count) {
                     unset($member['custom_fields'][$group]);
                 }
             }
         } else {
             if ($group == 'contact') {
                 $show_contact = false;
                 foreach ($member['custom_fields'][$group] as $key => $value) {
                     $_val = preg_replace('/<!--(.|\\s)*?-->/', '', $value);
                     if ($_val) {
                         $show_contact = true;
                         break;
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Format signature
     //-----------------------------------------
     if ($member['signature']) {
         IPSText::getTextClass('bbcode')->parse_html = $member['g_dohtml'];
         IPSText::getTextClass('bbcode')->parse_nl2br = 1;
         IPSText::getTextClass('bbcode')->parse_smilies = 0;
         IPSText::getTextClass('bbcode')->parse_bbcode = 1;
         IPSText::getTextClass('bbcode')->parsing_section = 'signatures';
         IPSText::getTextClass('bbcode')->parsing_mgroup = $member['member_group_id'];
         IPSText::getTextClass('bbcode')->parsing_mgroup_others = $member['mgroup_others'];
         $member['signature'] = IPSText::getTextClass('bbcode')->preDisplayParse($member['signature']);
         $member['signature'] = $this->registry->getClass('output')->getTemplate('global')->signature_separator($member['signature']);
     }
     //-----------------------------------------
     // Format 'About me'
     //-----------------------------------------
     if ($member['pp_about_me']) {
         IPSText::getTextClass('bbcode')->parse_html = $member['g_dohtml'];
         IPSText::getTextClass('bbcode')->parse_nl2br = 1;
         IPSText::getTextClass('bbcode')->parse_smilies = 1;
         IPSText::getTextClass('bbcode')->parse_bbcode = 1;
         IPSText::getTextClass('bbcode')->parsing_section = 'aboutme';
         IPSText::getTextClass('bbcode')->parsing_mgroup = $member['member_group_id'];
         IPSText::getTextClass('bbcode')->parsing_mgroup_others = $member['mgroup_others'];
         $member['pp_about_me'] = IPSText::getTextClass('bbcode')->preDisplayParse(IPSText::getTextClass('bbcode')->preDbParse($member['pp_about_me']));
     }
     /* final data */
     if ($default_tab == 'core:info') {
         /* Load status class */
         if (!$this->registry->isClassLoaded('memberStatus')) {
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/member/status.php', 'memberStatus');
             $this->registry->setClass('memberStatus', new $classToLoad(ipsRegistry::instance()));
         }
         /* Fetch */
         $status = $this->registry->getClass('memberStatus')->fetchMemberLatest($member['member_id']);
     }
     //-----------------------------------------
     // Warnings?
     //-----------------------------------------
     $warns = array();
     if ($member['show_warn']) {
         if ($member['member_banned']) {
             $warns['ban'] = 0;
             $_warn = ipsRegistry::DB()->buildAndFetch(array('select' => 'wl_id', 'from' => 'members_warn_logs', 'where' => "wl_member={$member['member_id']} AND wl_suspend<>0 AND wl_suspend<>-2", 'order' => 'wl_date DESC', 'limit' => 1));
             if ($_warn['wl_id']) {
                 $warns['ban'] = $_warn['wl_id'];
             }
         }
         if ($member['temp_ban']) {
             $warns['suspend'] = 0;
             $_warn = ipsRegistry::DB()->buildAndFetch(array('select' => 'wl_id', 'from' => 'members_warn_logs', 'where' => "wl_member={$member['member_id']} AND wl_suspend<>0 AND wl_suspend<>-2", 'order' => 'wl_date DESC', 'limit' => 1));
             if ($_warn['wl_id']) {
                 $warns['suspend'] = $_warn['wl_id'];
             }
         }
         if ($member['restrict_post']) {
             $warns['rpa'] = 0;
             $_warn = ipsRegistry::DB()->buildAndFetch(array('select' => 'wl_id', 'from' => 'members_warn_logs', 'where' => "wl_member={$member['member_id']} AND wl_rpa<>0", 'order' => 'wl_date DESC', 'limit' => 1));
             if ($_warn['wl_id']) {
                 $warns['rpa'] = $_warn['wl_id'];
             }
         }
         if ($member['mod_posts']) {
             $warns['mq'] = 0;
             $_warn = ipsRegistry::DB()->buildAndFetch(array('select' => 'wl_id', 'from' => 'members_warn_logs', 'where' => "wl_member={$member['member_id']} AND wl_mq<>0", 'order' => 'wl_date DESC', 'limit' => 1));
             if ($_warn['wl_id']) {
                 $warns['mq'] = $_warn['wl_id'];
             }
         }
     }
     //-----------------------------------------
     // Add to output
     //-----------------------------------------
     $this->request['member_id'] = intval($this->request['showuser']);
     $this->member_name = $member['members_display_name'];
     $this->output = $this->registry->getClass('output')->getTemplate('profile')->profileModern($tabs, $member, $visitors, $default_tab, $tab_html, $friends, $status, $warns, $show_contact);
 }
Beispiel #5
0
 /**
  * Show the forum leaders
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _showLeaders()
 {
     /* Load language */
     $this->lang->loadLanguageFile(array('public_online', 'public_profile'), 'members');
     /* Init */
     $st = intval($this->request['st']);
     $perpage = 25;
     $group_ids = array();
     $member_ids = array();
     $members = array();
     $forumsMembers = array();
     $pagination = '';
     $mids = array();
     $location_info = array();
     $whereClause = array();
     /* Work out who our super mods / mods aer */
     foreach ($this->cache->getCache('group_cache') as $i) {
         if ($i['g_is_supmod']) {
             $group_ids[$i['g_id']] = '*';
         } elseif ($i['g_access_cp']) {
             $group_ids[$i['g_id']] = array();
         }
     }
     $modCache = $this->cache->getCache('moderators');
     $modCache = is_array($modCache) && count($modCache) ? $modCache : array();
     foreach ($modCache as $i) {
         if ($i['is_group'] && !$this->caches['group_cache'][$i['group_id']]['gbw_hide_leaders_page']) {
             if (isset($group_ids[$i['group_id']])) {
                 if (is_array($group_ids[$i['group_id']])) {
                     $group_ids[$i['group_id']][$i['forum_id']] = ipsRegistry::getClass('class_forums')->forum_by_id[$i['forum_id']]['name'];
                 }
             } else {
                 $group_ids[$i['group_id']] = array($i['forum_id'] => ipsRegistry::getClass('class_forums')->forum_by_id[$i['forum_id']]['name']);
             }
         } else {
             if ($i['member_id']) {
                 $member_ids[$i['member_id']] = $i['member_id'];
                 $forumsMembers[$i['member_id']][$i['forum_id']] = ipsRegistry::getClass('class_forums')->forum_by_id[$i['forum_id']]['name'];
             }
         }
     }
     /* Custom Fields */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields');
     $custom_fields_class = new $classToLoad();
     //-----------------------------------------
     // Get em
     //-----------------------------------------
     /* Got groups? */
     if (count($group_ids)) {
         $whereClause[] = $this->DB->buildWherePermission(array_keys($group_ids), 'm.member_group_id', FALSE);
     }
     /* Got members? */
     if (count($member_ids)) {
         $whereClause[] = $this->DB->buildWherePermission(array_keys($member_ids), 'm.member_id', FALSE);
     }
     /* So we got something? If not skip the whole thing.. */
     if (count($whereClause)) {
         /* Get a count */
         $count = $this->DB->buildAndFetch(array('select' => 'count(*) as dracula', 'from' => array('members' => 'm'), 'where' => implode(' OR ', $whereClause)));
         if ($count['dracula']) {
             /* Sort out pagination */
             $pagination = $this->registry->output->generatePagination(array('totalItems' => $count['dracula'], 'itemsPerPage' => $perpage, 'currentStartValue' => $st, 'baseUrl' => "app=forums&module=extras&section=stats&do=leaders"));
             /* Fetch the ones we want */
             $this->DB->build(array('select' => 'm.*, m.member_id as my_member_id', 'from' => array('members' => 'm'), 'add_join' => array(array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'), array('select' => 'pf.*', 'from' => array('pfields_content' => 'pf'), 'where' => 'pf.member_id=m.member_id', 'type' => 'left')), 'where' => implode(' OR ', $whereClause), 'order' => 'm.members_display_name', 'limit' => array($st, $perpage)));
             $e = $this->DB->execute();
             while ($r = $this->DB->fetch($e)) {
                 /* Reset member ID just in case.. */
                 $r['member_id'] = $r['my_member_id'];
                 $members[$r['member_id']] = IPSMember::buildDisplayData($r);
             }
             /* Now fetch session data */
             $this->DB->build(array('select' => '*', 'from' => 'sessions', 'where' => 'member_id IN (' . implode(',', array_keys($members)) . ')'));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 if (!$r['id'] or IPSMember::isLoggedInAnon($members[$r['member_id']])) {
                     $location_info[$r['member_id']] = '';
                 } else {
                     $location_info[$r['member_id']] = IPSMember::getLocation($r);
                 }
             }
             //-----------------------------------------
             // Display
             //-----------------------------------------
             foreach ($members as $k => $member) {
                 $forums = isset($member_ids[$member['member_id']]) ? $member_ids[$member['member_id']] : array();
                 if ($forums == '*') {
                     $forums = $this->lang->words['leader_all_forums'];
                 } else {
                     $forums = array();
                     foreach ($group_ids as $gid => $fs) {
                         if (IPSMember::isInGroup($member, $gid)) {
                             if ($fs == '*') {
                                 $forums = $this->lang->words['leader_all_forums'];
                                 break;
                             } else {
                                 foreach ($fs as $f_id => $f_name) {
                                     if (!isset($forums[$f_id]) && $this->registry->getClass('class_forums')->forumsCheckAccess($f_id, 0, 'forum', array(), true)) {
                                         $forums[$f_id] = $f_name;
                                     }
                                 }
                             }
                         }
                     }
                     /* Now merge in member specific */
                     if (!is_string($forums) && !empty($forumsMembers[$member['member_id']])) {
                         foreach ($forumsMembers[$member['member_id']] as $f_id => $f_name) {
                             if (!isset($forums[$f_id]) && $this->registry->getClass('class_forums')->forumsCheckAccess($f_id, 0, 'forum', array(), true)) {
                                 $forums[$f_id] = $f_name;
                             }
                         }
                     }
                 }
                 /* Do not list if the user cannot see the forums this mod is a mod of - Bug report 36929 */
                 if (empty($forums)) {
                     unset($members[$k]);
                     continue;
                 }
                 $members[$k]['forums'] = $forums;
                 $members[$k]['online_extra'] = isset($location_info[$k]['online_extra']) ? $location_info[$k]['online_extra'] : '';
                 $members[$k]['last_active'] = $members[$k]['member_id'] == $this->memberData['member_id'] ? IPS_UNIX_TIME_NOW : ($members[$k]['online_extra'] ? $members[$k]['last_activity'] : $members[$k]['last_visit']);
             }
         }
     }
     $this->output .= $this->registry->getClass('output')->getTemplate('stats')->group_strip($this->lang->words['forum_leaders'], $members, $pagination);
     $this->registry->output->setTitle($this->lang->words['forum_leaders'] . ' - ' . ipsRegistry::$settings['board_name']);
     $this->registry->output->addNavigation($this->lang->words['forum_leaders'], '');
 }
 /**
  * Show the forum leaders
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _showLeaders()
 {
     //-----------------------------------------
     // Load online lang file
     //-----------------------------------------
     $this->lang->loadLanguageFile(array('public_online'), 'members');
     //-----------------------------------------
     // Work out who our super mods / mods aer
     //-----------------------------------------
     $group_ids = array();
     $member_ids = array();
     $used_ids = array();
     $members = array();
     $moderators = array();
     foreach ($this->cache->getCache('group_cache') as $i) {
         if ($i['g_is_supmod']) {
             $group_ids[$i['g_id']] = $i['g_id'];
         }
         if ($i['g_access_cp']) {
             $group_ids[$i['g_id']] = $i['g_id'];
         }
     }
     foreach ($this->cache->getCache('moderators') as $i) {
         if ($i['is_group']) {
             $group_ids[$i['group_id']] = $i['group_id'];
         } else {
             $member_ids[$i['member_id']] = $i['member_id'];
         }
     }
     /* Custom Fields */
     require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
     $custom_fields_class = new customProfileFields();
     //-----------------------------------------
     // Get all members.. (two is more eff. than 1)
     //-----------------------------------------
     if (count($member_ids)) {
         $this->DB->build(array('select' => 'm.*, m.member_id as user_member_id', 'from' => array('members' => 'm'), 'where' => "m.member_id IN(" . implode(',', $member_ids) . ")", 'order' => 'm.members_l_display_name', 'add_join' => array(array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'), array('select' => 's.*', 'from' => array('sessions' => 's'), 'where' => 's.member_id=m.member_id', 'type' => 'left'), array('select' => 'pf.*', 'from' => array('pfields_content' => 'pf'), 'where' => 'pf.member_id=m.member_id', 'type' => 'left'))));
         $outer = $this->DB->execute();
         while ($r = $this->DB->fetch($outer)) {
             $r['member_id'] = $r['user_member_id'];
             $r = IPSMember::buildDisplayData($r);
             $r = IPSMember::getLocation($r);
             $members[strtolower($r['members_display_name'])] = $r;
         }
     }
     //-----------------------------------------
     // Get all groups.. (two is more eff. than 1)
     //-----------------------------------------
     $this->DB->build(array('select' => 'm.*, m.member_id as user_member_id', 'from' => array('members' => 'm'), 'where' => "m.member_group_id IN(" . implode(',', $group_ids) . ")", 'add_join' => array(array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'), array('select' => 's.*', 'from' => array('sessions' => 's'), 'where' => 's.member_id=m.member_id', 'type' => 'left'), array('select' => 'pf.*', 'from' => array('pfields_content' => 'pf'), 'where' => 'pf.member_id=m.member_id', 'type' => 'left'))));
     $outer = $this->DB->execute();
     while ($r = $this->DB->fetch($outer)) {
         $r['member_id'] = $r['user_member_id'];
         $r = IPSMember::buildDisplayData($r);
         if (substr($r['login_anonymous'], 0, 1)) {
             $r['online_extra'] = '';
         } else {
             $r = IPSMember::getLocation($r);
         }
         $members[strtolower($r['members_display_name'])] = $r;
     }
     ksort($members);
     //-----------------------------------------
     // PRINT: Admins
     //-----------------------------------------
     $admins = array();
     $supmods = array();
     foreach ($members as $member) {
         if ($this->caches['group_cache'][$member['member_group_id']]['g_access_cp']) {
             $member['forums'] = $this->lang->words['leader_all_forums'];
             //-----------------------------------------
             // Used...
             //-----------------------------------------
             $used_ids[] = $member['member_id'];
             $admins[] = $member;
         }
     }
     $this->output .= $this->registry->getClass('output')->getTemplate('stats')->group_strip($this->lang->words['leader_admins'], $admins);
     //-----------------------------------------
     // PRINT: Super Moderators
     //-----------------------------------------
     foreach ($members as $member) {
         if ($this->caches['group_cache'][$member['member_group_id']]['g_is_supmod'] and !in_array($member['member_id'], $used_ids)) {
             $member['forums'] = $this->lang->words['leader_all_forums'];
             //-----------------------------------------
             // Used...
             //-----------------------------------------
             $used_ids[] = $member['member_id'];
             $supmods[] = $member;
         }
     }
     if (count($supmods)) {
         $this->output .= $this->registry->getClass('output')->getTemplate('stats')->group_strip($this->lang->words['leader_global'], $supmods);
     }
     //-----------------------------------------
     // GET MODERATORS: Normal
     //-----------------------------------------
     $tmp_html = "";
     foreach ($members as $member) {
         if (!in_array($member['member_id'], $used_ids)) {
             foreach ($this->cache->getCache('moderators') as $data) {
                 if ($data['is_group'] and $data['group_id'] == $member['member_group_id']) {
                     if (IPSMember::checkPermissions('read', $data['forum_id']) == TRUE) {
                         $moderators[] = array_merge($member, array('forum_id' => $data['forum_id']));
                     }
                     $used_ids[] = $member['member_id'];
                 } else {
                     if ($data['member_id'] == $member['member_id']) {
                         if (IPSMember::checkPermissions('read', $data['forum_id']) == TRUE) {
                             $moderators[] = array_merge($member, array('forum_id' => $data['forum_id']));
                         }
                         $used_ids[] = $member['member_id'];
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Parse moderators
     //-----------------------------------------
     if (count($moderators) > 0) {
         $mod_array = array();
         foreach ($moderators as $i) {
             if (!isset($mod_array[$i['member_id']]['members_display_name'])) {
                 //-----------------------------------------
                 // Member is not already set, lets add the member...
                 //-----------------------------------------
                 $mod_array[$i['member_id']] = $i;
             }
             //-----------------------------------------
             // Add forum..
             //-----------------------------------------
             $mod_array[$i['member_id']]['forums'][$i['forum_id']] = ipsRegistry::getClass('class_forums')->forum_by_id[$i['forum_id']]['name'];
         }
         if (count($mod_array)) {
             $this->output .= $this->registry->getClass('output')->getTemplate('stats')->group_strip($this->lang->words['leader_mods'], $mod_array);
         }
     }
     $this->registry->output->setTitle($this->lang->words['forum_leaders']);
     $this->registry->output->addNavigation($this->lang->words['forum_leaders'], '');
 }