/**
  * @param	string	key
  * @param	string	value
  */
 public function setMemberData($k, $v = '')
 {
     if (is_integer($k)) {
         $this->_memberData = empty($k) ? IPSMember::setUpGuest() : IPSMember::load($k, 'all');
     } else {
         if (is_string($k) && $k == intval($k)) {
             $this->_memberData = empty($k) ? IPSMember::setUpGuest() : IPSMember::load($k, 'all');
         } else {
             if (is_array($k)) {
                 $this->_memberData = $k;
             } else {
                 if (!empty($k)) {
                     $this->_memberData[$k] = $v;
                 }
             }
         }
     }
     /* Set perm ids and that */
     if ($this->memberData['member_id'] == $this->_memberData['member_id']) {
         $this->_memberData['_perm_id_array'] = $this->member->perm_id_array;
     } else {
         /* Force to guest for now */
         $permId = !empty($this->_memberData['org_perm_id']) ? $this->_memberData['org_perm_id'] : $this->_memberData['g_perm_id'];
         $this->_memberData['_perm_id_array'] = array_unique(explode(",", $permId));
     }
 }
示例#2
0
 /**
  * Process Results
  *
  * @param	array	Row from database using query specified in fetch()
  * @return	array	Same data with any additional processing necessary
  */
 public function process($row)
 {
     /* Build poster's display data */
     $member = $row['author_id'] ? IPSMember::load($row['author_id'], 'profile_portal,pfields_content,sessions,groups', 'id') : IPSMember::setUpGuest();
     $row = array_merge($row, IPSMember::buildDisplayData($member, array('reputation' => 0, 'warn' => 0)));
     /* Get forum data (damn HTML >.<) */
     $forumData = ipsRegistry::getClass('class_forums')->getForumById($row['forum_id']);
     /* Parse BBCode */
     IPSText::getTextClass('bbcode')->parse_smilies = $row['use_emo'];
     IPSText::getTextClass('bbcode')->parse_html = ($forumData['use_html'] and $member['g_dohtml'] and $row['post_htmlstate']) ? 1 : 0;
     IPSText::getTextClass('bbcode')->parse_nl2br = $row['post_htmlstate'] == 2 ? 1 : 0;
     IPSText::getTextClass('bbcode')->parse_bbcode = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'topics';
     IPSText::getTextClass('bbcode')->parsing_mgroup = $member['member_group_id'];
     IPSText::getTextClass('bbcode')->parsing_mgroup_others = $member['mgroup_others'];
     $row['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($row['post']);
     /* Parse attachments */
     $messageHTML = array($row['pid'] => $row['post']);
     $attachHTML = $this->class_attach->renderAttachments($messageHTML, array($row['pid']));
     if (is_array($attachHTML) and count($attachHTML)) {
         /* Get rid of any lingering attachment tags */
         if (stristr($attachHTML[$row['pid']]['html'], "[attachment=")) {
             $attachHTML[$row['pid']]['html'] = IPSText::stripAttachTag($attachHTML[$row['pid']]['html']);
         }
         $row['post'] = $attachHTML[$row['pid']]['html'] . $attachHTML[$row['pid']]['attachmentHtml'];
     }
     /* Get rep buttons */
     if ($row['repUserGiving'] == ipsRegistry::member()->getProperty('member_id')) {
         $row['has_given_rep'] = $row['rep_rating'];
     }
     $row['rep_points'] = ipsRegistry::getClass('repCache')->getRepPoints(array('app' => 'forums', 'type' => 'pid', 'type_id' => $row['pid'], 'rep_points' => $row['rep_points']));
     $row['repButtons'] = ipsRegistry::getClass('repCache')->getLikeFormatted(array('app' => 'forums', 'type' => 'pid', 'id' => $row['pid'], 'rep_like_cache' => $row['rep_like_cache']));
     /* Return */
     return $row;
 }
示例#3
0
 /**
  * Main class entry point
  *
  * @param	object		ipsRegistry reference
  * @return	@e void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // Get member data and format
     //-----------------------------------------
     $user = intval($this->request['user']);
     $id = intval($this->request['id']);
     if (!$user) {
         $this->returnString("no");
     }
     if ($id) {
         $member = IPSMember::buildDisplayData(IPSMember::load($id));
     } else {
         $member = IPSMember::buildDisplayData(IPSMember::setUpGuest($this->lang->words['global_guestname'] . "_" . $user));
     }
     //-----------------------------------------
     // Mod permissions
     //-----------------------------------------
     $my_groups = array($this->memberData['member_group_id']);
     if ($this->memberData['mgroup_others']) {
         $my_groups = array_merge($my_groups, explode(",", IPSText::cleanPermString($this->memberData['mgroup_others'])));
     }
     $permissions = 0;
     $private = 0;
     if ($this->settings['ipschat_mods']) {
         $mod_groups = explode(",", $this->settings['ipschat_mods']);
         foreach ($my_groups as $group_id) {
             if (in_array($group_id, $mod_groups)) {
                 $permissions = 1;
                 break;
             }
         }
     }
     if ($this->settings['ipschat_private']) {
         $mod_groups = explode(",", $this->settings['ipschat_private']);
         foreach ($my_groups as $group_id) {
             if (in_array($group_id, $mod_groups)) {
                 $private = 1;
                 break;
             }
         }
     }
     //-----------------------------------------
     // Return output
     //-----------------------------------------
     $this->returnJsonArray(array('html' => ipsRegistry::getClass('output')->replaceMacros($this->registry->getClass('output')->getTemplate('ipchat')->ajaxNewUser(array('user_id' => $user, 'moderator' => $permissions, 'private' => $private, 'member' => $member))), 'prefix' => $this->settings['ipschat_format_names'] ? str_replace('"', '__DBQ__', $member['prefix']) : '', 'suffix' => $this->settings['ipschat_format_names'] ? str_replace('"', '__DBQ__', $member['suffix']) : '', 'pp_small_photo' => $member['pp_small_photo'], 'name' => $member['members_display_name'], '_canBeIgnored' => $member['member_id'] ? $member['_canBeIgnored'] : 1, 'g_id' => $member['g_id']));
 }
 /**
  * @param	string	key
  * @param	string	value
  */
 public function setMemberData($k, $v = '')
 {
     if (is_integer($k)) {
         $this->_memberData = empty($k) ? IPSMember::setUpGuest() : IPSMember::load($k);
     } else {
         if (is_string($k) && $k == intval($k)) {
             $this->_memberData = empty($k) ? IPSMember::setUpGuest() : IPSMember::load($k);
         } else {
             if (is_array($k)) {
                 $this->_memberData = $k;
             } else {
                 if (!empty($k)) {
                     $this->_memberData[$k] = $v;
                 }
             }
         }
     }
     $this->_memberData = IPSMember::setUpModerator($this->_memberData);
 }
 /**
  * Constructor :: Authorizes the session
  *
  * @access	public
  * @return	mixed		Void normally, but can print error message
  */
 public function __construct()
 {
     /* Make object */
     $this->registry = ipsRegistry::instance();
     $this->DB = $this->registry->DB();
     $this->settings =& $this->registry->fetchSettings();
     $this->request =& $this->registry->fetchRequest();
     $this->cache = $this->registry->cache();
     $this->caches =& $this->registry->cache()->fetchCaches();
     $this->_member = self::instance();
     $this->_memberData =& self::instance()->fetchMemberData();
     /* Delete immediately */
     $this->_deleteNow = true;
     /**
      * If the sso.php file is present in this folder, we'll load it.
      * This file can be used to easily integrate single-sign on in
      * situations where you need to check session data
      */
     if (file_exists(IPS_ROOT_PATH . '/sources/classes/session/sso.php')) {
         require_once IPS_ROOT_PATH . '/sources/classes/session/sso.php';
         if (class_exists("ssoSessionExtension")) {
             $this->sso = new ssoSessionExtension($this->registry);
         }
     }
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $cookie = array();
     $this->_userAgent = substr($this->_member->user_agent, 0, 200);
     //-----------------------------------------
     // Fix up app / section / module
     //-----------------------------------------
     $this->current_appcomponent = IPS_APP_COMPONENT;
     $this->current_module = IPSText::alphanumericalClean($this->request['module']);
     $this->current_section = IPSText::alphanumericalClean($this->request['section']);
     $this->settings['session_expiration'] = $this->settings['session_expiration'] ? $this->settings['session_expiration'] : 3600;
     //-----------------------------------------
     // Return as guest if running a task
     //-----------------------------------------
     if (IPS_IS_TASK) {
         self::$data_store = IPSMember::setUpGuest();
         self::$data_store['last_activity'] = time();
         self::$data_store['last_visit'] = time();
         return true;
     }
     //-----------------------------------------
     // no new headers if we're simply viewing an attachment..
     //-----------------------------------------
     if ($this->request['section'] == 'attach') {
         $this->settings['no_print_header'] = 1;
     }
     //-----------------------------------------
     // no new headers if we're updating chat
     //-----------------------------------------
     if (IPS_IS_AJAX && $this->request['section'] != 'login' or $this->request['section'] == 'attach' or $this->request['section'] == 'captcha') {
         $this->settings['no_print_header'] = 1;
         $this->do_update = 0;
     }
     //-----------------------------------------
     // Continue!
     //-----------------------------------------
     $cookie['session_id'] = IPSCookie::get('session_id');
     $cookie['member_id'] = IPSCookie::get('member_id');
     $cookie['pass_hash'] = IPSCookie::get('pass_hash');
     if ($cookie['session_id']) {
         $this->getSession($cookie['session_id']);
         $this->session_type = 'cookie';
     } elseif (isset($this->request['s']) and $this->request['s']) {
         $this->getSession($this->request['s']);
         $this->session_type = 'url';
     } else {
         $this->session_id = 0;
     }
     //-----------------------------------------
     // Do we have a valid session ID?
     //-----------------------------------------
     if ($this->session_id) {
         //-----------------------------------------
         // We've checked the IP addy and browser, so we can assume that this is
         // a valid session.
         //-----------------------------------------
         if ($this->session_user_id != 0 and !empty($this->session_user_id)) {
             //-----------------------------------------
             // It's a member session, so load the member.
             //-----------------------------------------
             self::setMember($this->session_user_id);
             //-----------------------------------------
             // Did we get a member?
             //-----------------------------------------
             if (!self::$data_store['member_id'] or self::$data_store['member_id'] == 0) {
                 $this->_updateGuestSession();
                 /**
                  * If we have an SSO object, run it for the update guest session call
                  */
                 if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForGuest')) {
                     $this->sso->checkSSOForGuest('update');
                 }
             } else {
                 $this->_updateMemberSession();
                 /**
                  * If we have an SSO object, run it for the update member call
                  */
                 if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForMember')) {
                     $this->sso->checkSSOForMember('update');
                 }
             }
         } else {
             $this->_updateGuestSession();
             /**
              * If we have an SSO object, run it for the update guest call
              */
             if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForGuest')) {
                 $this->sso->checkSSOForGuest('update');
             }
         }
     } else {
         //-----------------------------------------
         // We didn't have a session, or the session didn't validate
         // Do we have cookies stored?
         //-----------------------------------------
         if ($cookie['member_id'] != "" and $cookie['pass_hash'] != "") {
             //-----------------------------------------
             // Load member
             //-----------------------------------------
             self::setMember($cookie['member_id']);
             //-----------------------------------------
             // INIT log in key stuff
             //-----------------------------------------
             $_ok = 1;
             $_days = 0;
             $_sticky = 1;
             $_time = $this->settings['login_key_expire'] ? time() + intval($this->settings['login_key_expire']) * 86400 : 0;
             if (!self::$data_store['member_id'] or self::$data_store['member_id'] == 0) {
                 $this->_createGuestSession();
                 /**
                  * If we have an SSO object, run it for the create guest call
                  */
                 if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForGuest')) {
                     $this->sso->checkSSOForGuest('create');
                 }
             } else {
                 if (self::$data_store['member_login_key'] == $cookie['pass_hash']) {
                     //-----------------------------------------
                     // Key expired?
                     //-----------------------------------------
                     if ($this->settings['login_key_expire']) {
                         $_sticky = 0;
                         $_days = $this->settings['login_key_expire'];
                         if (time() > self::$data_store['member_login_key_expire']) {
                             $_ok = 0;
                         }
                     }
                     if ($_ok == 1) {
                         $this->_createMemberSession();
                         /**
                          * If we have an SSO object, run it for the create member call
                          */
                         if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForMember')) {
                             $this->sso->checkSSOForMember('create');
                         }
                         //-----------------------------------------
                         // Change the log in key to make each authentication
                         // use a unique token. This means that if a cookie is
                         // stolen, the hacker can only use the auth once.
                         //-----------------------------------------
                         if ($this->settings['login_change_key']) {
                             self::$data_store['member_login_key'] = IPSMember::generateAutoLoginKey();
                             IPSMember::save(self::$data_store['member_id'], array('core' => array('member_login_key' => self::$data_store['member_login_key'], 'member_login_key_expire' => $_time)));
                             IPSCookie::set("pass_hash", self::$data_store['member_login_key'], $_sticky, $_days);
                         }
                     } else {
                         self::setMember(0);
                         $this->_createGuestSession();
                         /**
                          * If we have an SSO object, run it for the create guest call
                          */
                         if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForGuest')) {
                             $this->sso->checkSSOForGuest('create');
                         }
                     }
                 } else {
                     self::setMember(0);
                     $this->_createGuestSession();
                     /**
                      * If we have an SSO object, run it for the create guest call
                      */
                     if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForGuest')) {
                         $this->sso->checkSSOForGuest('create');
                     }
                 }
             }
         } else {
             $this->_createGuestSession();
             /**
              * If we have an SSO object, run it for the create guest call
              */
             if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForGuest')) {
                 $this->sso->checkSSOForGuest('create');
             }
         }
     }
     //-----------------------------------------
     // Knock out Google Web Accelerator
     //-----------------------------------------
     if (ipsRegistry::$settings['disable_prefetching']) {
         if (my_getenv('HTTP_X_MOZ') and strstr(strtolower(my_getenv('HTTP_X_MOZ')), 'prefetch') and self::$data_store['member_id']) {
             if (IPB_PHP_SAPI == 'cgi-fcgi' or IPB_PHP_SAPI == 'cgi') {
                 @header('Status: 403 Forbidden');
             } else {
                 @header('HTTP/1.1 403 Forbidden');
             }
             @header("Cache-Control: no-cache, must-revalidate, max-age=0");
             @header("Expires: 0");
             @header("Pragma: no-cache");
             print "Prefetching or precaching is not allowed. If you have Google Accelerator enabled, please disable";
             exit;
         }
     }
     //-----------------------------------------
     // Still no member id and not a bot?
     //-----------------------------------------
     if (!self::$data_store['member_id'] and !$this->_member->is_not_human) {
         self::setMember(0);
         self::$data_store['last_activity'] = time();
         $this->request['last_visit'] = time();
     }
     //-----------------------------------------
     // Set a session ID cookie
     //-----------------------------------------
     $this->_member->session_type = $this->session_type;
     $this->_member->session_id = $this->session_id;
     IPSCookie::set("session_id", $this->session_id, -1);
 }
示例#6
0
 /**
  * Displays a report
  *
  * @return	@e void
  */
 public function _displayReport()
 {
     //-----------------------------------------
     // Lets make sure this report exists...
     //-----------------------------------------
     $rid = intval($this->request['rid']);
     $options = array('rid' => $rid);
     $reports = array();
     $comments = array();
     if (!$rid) {
         $this->registry->output->showError('reports_no_rid', 10137);
     }
     $this->registry->class_localization->loadLanguageFile(array('public_editors'));
     $report_index = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'rc_reports_index', 'where' => "id=" . $rid));
     //-----------------------------------------
     // Basic title and nav routine..
     //-----------------------------------------
     $this->registry->output->addNavigation($this->lang->words['main_title'], 'app=core&amp;module=reports&amp;do=index');
     $this->registry->output->addNavigation($report_index['title'], '');
     if (!$report_index['id']) {
         $this->registry->output->showError('reports_no_rid', 10138);
     }
     $COM_PERM = $this->registry->getClass('reportLibrary')->buildQueryPermissions();
     /* Load parser */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
     $parser = new $classToLoad();
     //-----------------------------------------
     // Get reports
     //-----------------------------------------
     $this->DB->buildFromCache('grab_report', array('COM' => $COM_PERM, 'rid' => $rid), 'report_sql_queries');
     $outer = $this->DB->execute();
     while ($row = $this->DB->fetch($outer)) {
         $row['points'] = isset($row['points']) ? $row['points'] : $this->settings['_tmpPoints'][$row['id']];
         if (!$options['url'] && $row['url']) {
             $options['url'] = $this->registry->getClass('reportLibrary')->processUrl($row['url'], $row['seoname'], $row['seotemplate']);
         }
         if (!$options['class'] && $row['my_class']) {
             $options['class'] = $row['my_class'];
         }
         if ($row['my_class'] == 'messages' && !$options['topicID'] && $row['exdat1']) {
             $options['topicID'] = intval($row['exdat1']);
         }
         $options['title'] = $row['title'];
         $options['status_id'] = $row['status'];
         if (!$options['status_icon']) {
             $options['status_icon'] = $this->registry->getClass('reportLibrary')->buildStatusIcon($row);
             $options['status_text'] = $this->registry->getClass('reportLibrary')->flag_cache[$row['status']][$row['points']]['title'];
         }
         /* Stupid stupid stupidness */
         $row['_title'] = $row['title'];
         $row['title'] = $row['member_title'];
         if ($row['member_id']) {
             $row['author'] = IPSMember::buildDisplayData($row);
         } else {
             $row['author'] = IPSMember::buildDisplayData(IPSMember::setUpGuest(''));
         }
         $row['title'] = $row['_title'];
         /* Set up some settings */
         $parser->set(array('parseArea' => 'reports', 'memberData' => $row['author'], 'parseBBCode' => true, 'parseHtml' => false, 'parseEmoticons' => true));
         $row['report'] = $parser->display($row['report']);
         $reports[] = $row;
     }
     if (!$options['class']) {
         $this->registry->output->showError('reports_no_rid', 10138);
     }
     $_tmp = $this->registry->getClass('reportLibrary')->flag_cache;
     // Manually build array get just the statuses, not severities
     foreach ($_tmp as $sid => $sta) {
         if (is_array($sta) && count($sta)) {
             foreach ($sta as $points => $info) {
                 if ($options['statuses'][$sid]) {
                     break;
                 }
                 $options['statuses'][$sid] = $info;
             }
         }
     }
     //-----------------------------------------
     // Get comments
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/comments/bootstrap.php';
     /*noLibHook*/
     $this->_comments = classes_comments_bootstrap::controller('core-reports');
     $comments = array('html' => $this->_comments->fetchFormatted($report_index, array('offset' => intval($this->request['st']))), 'count' => $this->_comments->count($report_index));
     //-----------------------------------------
     // Mark as read
     //-----------------------------------------
     $this->registry->classItemMarking->markRead(array('forumID' => 0, 'itemID' => $rid), 'core');
     //-----------------------------------------
     // And output
     //-----------------------------------------
     $this->output .= $this->registry->getClass('output')->getTemplate('reports')->viewReport($options, $reports, $comments);
 }
 /**
  * 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);
 }
示例#8
0
 /**
  * Parse search results
  *
  * @param	array 	$r			Search result
  * @return	array 	$html		Blocks of HTML
  */
 public function parseAndFetchHtmlBlocks($rows)
 {
     /* Forum stuff */
     $sub = false;
     $isVnc = false;
     $search_term = IPSSearchRegistry::get('in.clean_search_term');
     $noPostPreview = IPSSearchRegistry::get('opt.noPostPreview');
     $results = array();
     $attachPids = array();
     /* loop and process */
     foreach ($rows as $id => $data) {
         /* Reset */
         $pages = 0;
         /* Set up forum */
         $forum = $this->registry->getClass('class_forums')->forum_by_id[$data['forum_id']];
         $this->last_topic = $data['tid'];
         /* Various data */
         $data['_last_post'] = $data['last_post'];
         $data['_longTitle'] = $data['content_title'];
         $data['_shortTitle'] = IPSText::mbstrlen(strip_tags($data['content_title'])) > 60 ? IPSText::truncate($data['content_title'], 60) : $data['content_title'];
         $data['last_poster'] = $data['last_poster_id'] ? IPSMember::buildDisplayData($data['last_poster_id']) : IPSMember::buildDisplayData(IPSMember::setUpGuest($this->settings['guest_name_pre'] . $data['last_poster_name'] . $this->settings['guest_name_suf']));
         $data['starter'] = $data['starter_id'] ? IPSMember::makeProfileLink($data['starter_name'], $data['starter_id'], $data['seo_first_name']) : $this->settings['guest_name_pre'] . $data['starter_name'] . $this->settings['guest_name_suf'];
         //$data['last_post']   = $this->registry->getClass( 'class_localization')->getDate( $data['last_post'], 'SHORT' );
         if (isset($data['post_date'])) {
             $data['_post_date'] = $data['post_date'];
             //$data['post_date']	= $this->registry->getClass( 'class_localization')->getDate( $data['post_date'], 'SHORT' );
         }
         if ($this->registry->getClass('class_forums')->canQueuePosts($forum['id'])) {
             $data['posts'] += intval($data['topic_queuedposts']);
         }
         if ($this->registry->getClass('class_forums')->canSeeSoftDeletedPosts($forum['id'])) {
             $data['posts'] += intval($data['topic_deleted_posts']);
         }
         if ($data['posts']) {
             if (($data['posts'] + 1) % $this->settings['display_max_posts'] == 0) {
                 $pages = ($data['posts'] + 1) / $this->settings['display_max_posts'];
             } else {
                 $number = ($data['posts'] + 1) / $this->settings['display_max_posts'];
                 $pages = ceil($number);
             }
         }
         if ($pages > 1) {
             for ($i = 0; $i < $pages; ++$i) {
                 $real_no = $i * $this->settings['display_max_posts'];
                 $page_no = $i + 1;
                 if ($page_no == 4 and $pages > 4) {
                     $data['pages'][] = array('last' => 1, 'st' => ($pages - 1) * $this->settings['display_max_posts'], 'page' => $pages, 'total' => $pages);
                     break;
                 } else {
                     $data['pages'][] = array('last' => 0, 'st' => $real_no, 'page' => $page_no, 'total' => $pages);
                 }
             }
         }
         /* For-matt some stuffs */
         if (IPSSearchRegistry::get('opt.noPostPreview') != true) {
             if (!$data['cache_content']) {
                 IPSText::getTextClass('bbcode')->parse_smilies = $data['use_emo'];
                 IPSText::getTextClass('bbcode')->parse_html = ($forum['use_html'] and $this->caches['group_cache'][$data['member_group_id']]['g_dohtml'] and $data['post_htmlstate']) ? 1 : 0;
                 IPSText::getTextClass('bbcode')->parse_nl2br = $data['post_htmlstate'] == 2 ? 1 : 0;
                 IPSText::getTextClass('bbcode')->parse_bbcode = $forum['use_ibc'];
                 IPSText::getTextClass('bbcode')->parsing_section = 'topics';
                 IPSText::getTextClass('bbcode')->parsing_mgroup = $data['member_group_id'];
                 IPSText::getTextClass('bbcode')->parsing_mgroup_others = $data['mgroup_others'];
                 $data['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($data['post']);
             } else {
                 $data['post'] = '<!--cached-' . gmdate('r', $data['cache_updated']) . '-->' . $data['cache_content'];
             }
             $data['post'] = IPSText::searchHighlight($data['post'], $search_term);
         }
         /* Has attachments */
         if ($data['topic_hasattach']) {
             $attachPids[$data['pid']] = $data['post'];
         }
         $rows[$id] = $data;
     }
     /* Attachments */
     if (count($attachPids) and IPSSearchRegistry::get('set.returnType') != 'tids') {
         /* Load attachments class */
         if (!is_object($this->class_attach)) {
             $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php', 'class_attach');
             $this->class_attach = new $classToLoad($this->registry);
             $this->class_attach->type = 'post';
             $this->class_attach->init();
         }
         $attachHTML = $this->class_attach->renderAttachments($attachPids, array_keys($attachPids));
         /* Now parse back in the rendered posts */
         if (is_array($attachHTML) and count($attachHTML)) {
             foreach ($attachHTML as $id => $_data) {
                 /* Get rid of any lingering attachment tags */
                 if (stristr($_data['html'], "[attachment=")) {
                     $_data['html'] = IPSText::stripAttachTag($_data['html']);
                 }
                 $rows[$id]['post'] = $_data['html'];
                 $rows[$id]['attachmentHtml'] = $_data['attachmentHtml'];
             }
         }
     }
     /* Go through and build HTML */
     foreach ($rows as $id => $data) {
         /* Format content */
         list($html, $sub) = $this->formatContent($data);
         $results[$id] = array('html' => $html, 'app' => $data['app'], 'type' => $data['type'], 'sub' => $sub, '_followData' => !empty($data['_followData']) ? $data['_followData'] : array());
     }
     return $results;
 }
示例#9
0
 /**
  * Magic Call method
  *
  * @param	string	Method Name
  * @param	mixed	Method arguments
  * @return	mixed
  * Exception codes:
  */
 public function __call($method, $arguments)
 {
     $firstBit = substr($method, 0, 3);
     $theRest = substr($method, 3);
     if (in_array($theRest, $this->_allowedInternalData)) {
         if ($firstBit == 'set') {
             if ($theRest == 'Author') {
                 if (is_array($arguments[0])) {
                     $this->_internalData[$theRest] = $arguments[0];
                 } else {
                     if ($arguments[0]) {
                         /* Set up moderator stuff, too */
                         $this->_internalData[$theRest] = IPSMember::setUpModerator(IPSMember::load(intval($arguments[0]), 'all'));
                         /* And ignored users */
                         $this->_internalData[$theRest]['ignored_users'] = array();
                         $this->registry->DB()->build(array('select' => '*', 'from' => 'ignored_users', 'where' => "ignore_owner_id=" . intval($arguments[0])));
                         $this->registry->DB()->execute();
                         while ($r = $this->registry->DB()->fetch()) {
                             $this->_internalData[$theRest]['ignored_users'][] = $r['ignore_ignore_id'];
                         }
                     } else {
                         $this->_internalData[$theRest] = IPSMember::setUpGuest();
                     }
                 }
                 if ($this->_internalData['Author']['mgroup_others']) {
                     $_others = explode(',', IPSText::cleanPermString($this->_internalData['Author']['mgroup_others']));
                     $_perms = array();
                     foreach ($_others as $_other) {
                         $_perms[] = $this->caches['group_cache'][$_other]['g_perm_id'];
                     }
                     if (count($_perms)) {
                         $this->_internalData['Author']['g_perm_id'] = $this->_internalData['Author']['g_perm_id'] . ',' . implode(',', $_perms);
                     }
                 }
             } else {
                 $this->_internalData[$theRest] = $arguments[0];
                 return TRUE;
             }
         } else {
             if (($theRest == 'Author' or $theRest == 'Settings' or $theRest == 'ModOptions') and isset($arguments[0])) {
                 return isset($this->_internalData[$theRest][$arguments[0]]) ? $this->_internalData[$theRest][$arguments[0]] : '';
             } else {
                 return isset($this->_internalData[$theRest]) ? $this->_internalData[$theRest] : '';
             }
         }
     } else {
         switch ($method) {
             case 'setForumData':
                 $this->_forumData = $arguments[0];
                 break;
             case 'setPostData':
                 $this->_postData = $arguments[0];
                 break;
             case 'setTopicData':
                 $this->_topicData = $arguments[0];
                 break;
             case 'getForumData':
                 if (!empty($arguments[0])) {
                     return $this->_forumData[$arguments[0]];
                 } else {
                     return $this->_forumData;
                 }
                 break;
             case 'getPostData':
                 if (!empty($arguments[0])) {
                     return $this->_postData[$arguments[0]];
                 } else {
                     return $this->_postData;
                 }
                 break;
             case 'getTopicData':
                 if (!empty($arguments[0])) {
                     return $this->_topicData[$arguments[0]];
                 } else {
                     return $this->_topicData;
                 }
                 break;
             case 'getPostError':
                 return isset($this->lang->words[$this->_postErrors]) ? $this->lang->words[$this->_postErrors] : $this->_postErrors;
                 break;
         }
     }
 }
 /**
  * Gets the posts to be printed/downloaded
  *
  * @access	protected
  * @return	string
  **/
 protected function getPosts()
 {
     //-----------------------------------------
     // Render the page top
     //-----------------------------------------
     $posts_html = $this->registry->getClass('output')->getTemplate('printpage')->pp_header($this->forum['name'], $this->topic['title'], $this->topic['starter_name'], $this->forum['id'], $this->topic['tid']);
     $max_posts = 300;
     $attach_pids = array();
     $this->DB->build(array('select' => 'p.*', 'from' => array('posts' => 'p'), 'where' => "p.topic_id={$this->topic['tid']} and p.queued=0", 'order' => 'p.pid', 'limit' => array(0, $max_posts), 'add_join' => array(array('select' => 'm.members_display_name', 'from' => array('members' => 'm'), 'where' => 'm.member_id=p.author_id', 'type' => 'left'))));
     $this->DB->execute();
     //-----------------------------------------
     // Loop through to pick out the correct member IDs.
     // and push the post info into an array - maybe in the future
     // we can add page spans, or maybe save to a PDF file?
     //-----------------------------------------
     $the_posts = array();
     $mem_ids = array();
     $member_array = array();
     $cached_members = array();
     while ($i = $this->DB->fetch()) {
         $the_posts[] = $i;
         if ($i['author_id']) {
             $mem_ids[$i['author_id']] = $i['author_id'];
         }
     }
     //-----------------------------------------
     // Get the member profiles needed for this topic
     //-----------------------------------------
     if (count($mem_ids)) {
         $this->DB->build(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id IN (' . implode(',', $mem_ids) . ')', 'add_join' => array(array('select' => 'g.*', 'from' => array('groups' => 'g'), 'where' => 'g.g_id=m.member_group_id', 'type' => 'left'))));
         $this->DB->execute();
         while ($m = $this->DB->fetch()) {
             $member_array[$m['member_id']] = $m;
         }
     }
     //-----------------------------------------
     // Format and print out the topic list
     //-----------------------------------------
     foreach ($the_posts as $row) {
         $poster = array();
         //-----------------------------------------
         // Get the member info. We parse the data and cache it.
         // It's likely that the same member posts several times in
         // one page, so it's not efficient to keep parsing the same
         // data
         //-----------------------------------------
         if ($row['author_id'] != 0) {
             //-----------------------------------------
             // Is it in the hash?
             //-----------------------------------------
             if (isset($cached_members[$row['author_id']])) {
                 //-----------------------------------------
                 // Ok, it's already cached, read from it
                 //-----------------------------------------
                 $poster = $cached_members[$row['author_id']];
                 $row['name_css'] = 'normalname';
             } else {
                 //-----------------------------------------
                 // Ok, it's NOT in the cache, is it a member thats
                 // not been deleted?
                 //-----------------------------------------
                 if ($member_array[$row['author_id']]) {
                     $row['name_css'] = 'normalname';
                     $poster = $member_array[$row['author_id']];
                     //-----------------------------------------
                     // Add it to the cached list
                     //-----------------------------------------
                     $cached_members[$row['author_id']] = $poster;
                 } else {
                     //-----------------------------------------
                     // It's probably a deleted member, so treat them as a guest
                     //-----------------------------------------
                     $poster = IPSMember::setUpGuest($row['author_id']);
                     $row['name_css'] = 'unreg';
                 }
             }
         } else {
             //-----------------------------------------
             // It's definately a guest...
             //-----------------------------------------
             $poster = IPSMember::setUpGuest($row['author_name']);
             $row['name_css'] = 'unreg';
         }
         //-----------------------------------------
         $row['post'] = preg_replace("/<!--EDIT\\|(.+?)\\|(.+?)-->/", "", $row['post']);
         //-----------------------------------------
         $row['post_date'] = $this->registry->getClass('class_localization')->getDate($row['post_date'], 'LONG', 1);
         //-----------------------------------------
         // Quoted attachments?
         //-----------------------------------------
         $attach_pids[$row['pid']] = $row['pid'];
         $row['post'] = $this->parseMessage($row['post'], $row);
         //-----------------------------------------
         // Parse HTML tag on the fly
         //-----------------------------------------
         $posts_html .= $this->registry->getClass('output')->getTemplate('printpage')->pp_postentry($poster, $row);
     }
     if (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->type = 'post';
             $this->class_attach->init();
         }
         $posts_html = $this->class_attach->renderAttachments($posts_html, $attach_pids);
         $posts_html = $posts_html[0]['html'];
     }
     //-----------------------------------------
     // Print the footer
     //-----------------------------------------
     $posts_html .= $this->registry->getClass('output')->getTemplate('printpage')->pp_end();
     //-----------------------------------------
     // Macros
     //-----------------------------------------
     $posts_html = $this->registry->getClass('output')->replaceMacros($posts_html);
     //-----------------------------------------
     // CSS
     //-----------------------------------------
     $this->registry->getClass('output')->skin['_usecsscache'] = 0;
     return $posts_html;
 }
 /**
  * Set current member to the member ID specified
  *
  * @param	integer	Member ID
  * @return	@e void
  */
 public static function setMember($member_id)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $member_id = intval($member_id);
     $addrs = array();
     //-----------------------------------------
     // If we have a member ID, set up the member
     //-----------------------------------------
     if ($member_id) {
         self::instance()->data_store = IPSMember::load($member_id, 'extendedProfile,customFields,groups,itemMarkingStorage');
     }
     /* Got a member ID? */
     if (!empty($member_id) && self::instance()->data_store['member_id']) {
         self::setUpMember();
         # Form hash
         self::instance()->form_hash = md5(self::instance()->data_store['email'] . '&' . self::instance()->data_store['member_login_key'] . '&' . self::instance()->data_store['joined']);
     } else {
         self::instance()->data_store = IPSMember::setUpGuest();
         self::instance()->perm_id = !empty(self::instance()->data_store['org_perm_id']) ? self::instance()->data_store['org_perm_id'] : self::instance()->data_store['g_perm_id'];
         self::instance()->perm_id_array = explode(',', self::instance()->perm_id);
         # Form hash
         self::instance()->form_hash = md5("this is only here to prevent it breaking on guests");
     }
     //-----------------------------------------
     // Set member data
     //-----------------------------------------
     self::instance()->member_id = $member_id;
 }
 /**
  * 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&amp;section=comments&amp;module=profile&amp;member_id=' . $member_id . '&amp;do=view&amp;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);
 }
 /**
  * Magic Call method
  *
  * @access	public
  * @param	string	Method Name
  * @param	mixed	Method arguments
  * @return	mixed
  * Exception codes:
  */
 public function __call($method, $arguments)
 {
     $firstBit = substr($method, 0, 3);
     $theRest = substr($method, 3);
     if (in_array($theRest, $this->_allowedInternalData)) {
         if ($firstBit == 'set') {
             if ($theRest == 'Author') {
                 if (is_array($arguments[0])) {
                     $this->_internalData[$theRest] = $arguments[0];
                 } else {
                     if ($arguments[0]) {
                         /* Set up moderator stuff, too */
                         $this->_internalData[$theRest] = $this->registry->getClass('class_forums')->setUpModerator(IPSMember::load(intval($arguments[0]), 'all'));
                         /* And ignored users */
                         $this->_internalData[$theRest]['ignored_users'] = array();
                         $this->registry->DB()->build(array('select' => '*', 'from' => 'ignored_users', 'where' => "ignore_owner_id=" . intval($arguments[0])));
                         $this->registry->DB()->execute();
                         while ($r = $this->registry->DB()->fetch()) {
                             $this->_internalData[$theRest]['ignored_users'][] = $r['ignore_ignore_id'];
                         }
                     } else {
                         $this->_internalData[$theRest] = IPSMember::setUpGuest();
                     }
                 }
             } else {
                 $this->_internalData[$theRest] = $arguments[0];
                 return TRUE;
             }
         } else {
             if (($theRest == 'Author' or $theRest == 'Settings' or $theRest == 'ModOptions') and isset($arguments[0])) {
                 return isset($this->_internalData[$theRest][$arguments[0]]) ? $this->_internalData[$theRest][$arguments[0]] : '';
             } else {
                 return isset($this->_internalData[$theRest]) ? $this->_internalData[$theRest] : '';
             }
         }
     } else {
         switch ($method) {
             case 'setForumData':
                 $this->_forumData = $arguments[0];
                 break;
             case 'setPostData':
                 $this->_postData = $arguments[0];
                 break;
             case 'setTopicData':
                 $this->_topicData = $arguments[0];
                 break;
             case 'getForumData':
                 if ($arguments[0]) {
                     return $this->_forumData[$arguments[0]];
                 } else {
                     return $this->_forumData;
                 }
                 break;
             case 'getPostData':
                 if ($arguments[0]) {
                     return $this->_postData[$arguments[0]];
                 } else {
                     return $this->_postData;
                 }
                 break;
             case 'getTopicData':
                 if ($arguments[0]) {
                     return $this->_topicData[$arguments[0]];
                 } else {
                     return $this->_topicData;
                 }
                 break;
             case 'getPostError':
                 return $this->lang->words[$this->_postErrors];
                 break;
         }
     }
 }
示例#14
0
 /**
  * Builds an array of post data for output
  *
  * @param	array	$row	Array of post data
  * @return	array
  */
 public function parsePost(array $post)
 {
     /* Init */
     $topicData = $this->getTopicData();
     $forumData = $this->registry->getClass('class_forums')->getForumById($topicData['forum_id']);
     $permissionData = $this->getPermissionData();
     /* Start memory debug */
     $_NOW = IPSDebug::getMemoryDebugFlag();
     $poster = array();
     /* Bitwise options */
     $_tmp = IPSBWOptions::thaw($post['post_bwoptions'], 'posts', 'forums');
     if (count($_tmp)) {
         foreach ($_tmp as $k => $v) {
             $post[$k] = $v;
         }
     }
     /* Is this a member? */
     if ($post['author_id'] != 0) {
         $poster = $this->parseMember($post);
     } else {
         /* Sort out guest */
         $post['author_name'] = $this->settings['guest_name_pre'] . $post['author_name'] . $this->settings['guest_name_suf'];
         $poster = IPSMember::setUpGuest($post['author_name']);
         $poster['members_display_name'] = $post['author_name'];
         $poster['_members_display_name'] = $post['author_name'];
         $poster['custom_fields'] = "";
         $poster['warn_img'] = "";
         $poster = IPSMember::buildProfilePhoto($poster);
     }
     /* Memory debug */
     IPSDebug::setMemoryDebugFlag("PID: " . $post['pid'] . " - Member Parsed", $_NOW);
     /* Update permission */
     $this->registry->getClass('class_forums')->setMemberData($this->getMemberData());
     $permissionData['softDelete'] = $this->registry->getClass('class_forums')->canSoftDeletePosts($topicData['forum_id'], $post);
     /* Soft delete */
     $post['_softDelete'] = $post['pid'] != $topicData['topic_firstpost'] ? $permissionData['softDelete'] : FALSE;
     $post['_softDeleteRestore'] = $permissionData['softDeleteRestore'];
     $post['_softDeleteSee'] = $permissionData['softDeleteSee'];
     $post['_softDeleteReason'] = $permissionData['softDeleteReason'];
     $post['_softDeleteContent'] = $permissionData['softDeleteContent'];
     $post['_isVisible'] = $this->registry->getClass('class_forums')->fetchHiddenType($post) == 'visible' ? true : false;
     $post['_isHidden'] = $this->registry->getClass('class_forums')->fetchHiddenType($post) == 'hidden' ? true : false;
     $post['_isDeleted'] = $this->registry->getClass('class_forums')->fetchHiddenType($post) == 'sdelete' ? true : false;
     /* Answered post */
     try {
         $post['_isMarkedAnswered'] = $this->postIsAnswer($post, $topicData) ? true : false;
     } catch (Exception $e) {
         $post['_isMarkedAnswered'] = false;
     }
     $post['_canMarkUnanswered'] = $post['_isMarkedAnswered'] === true && $this->canUnanswerTopic($topicData) ? true : false;
     $post['_canAnswer'] = $post['_isMarkedAnswered'] === false && $this->canAnswerTopic($topicData) ? true : false;
     $post['PermalinkUrlBit'] = '';
     /* Queued */
     if ($topicData['topic_firstpost'] == $post['pid'] and ($post['_isHidden'] or $topicData['_isHidden'])) {
         $post['queued'] = 1;
         $post['_isHidden'] = true;
     }
     if ($topicData['topic_queuedposts'] || $topicData['topic_deleted_posts']) {
         if ($topicData['topic_queuedposts'] && $topicData['Perms']['canQueuePosts']) {
             /* We have hidden data that is viewable */
             $post['PermalinkUrlBit'] = '&amp;p=' . $post['pid'];
         }
         if ($topicData['topic_deleted_posts'] && $post['_softDeleteSee']) {
             /* We have hidden data that is viewable */
             $post['PermalinkUrlBit'] = '&amp;p=' . $post['pid'];
         }
     }
     /* Edited stuff */
     $post['edit_by'] = "";
     if ($post['append_edit'] == 1 and $post['edit_time'] != "" and $post['edit_name'] != "") {
         $e_time = $this->registry->class_localization->getDate($post['edit_time'], 'LONG');
         $post['edit_by'] = sprintf($this->lang->words['edited_by'], $post['edit_name'], $e_time);
     }
     /* Now parse the post */
     if (!isset($post['cache_content']) or !$post['cache_content']) {
         $_NOW2 = IPSDebug::getMemoryDebugFlag();
         /* Grab the parser file */
         if ($this->_parser === null) {
             /* Load parser */
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
             $this->_parser = new $classToLoad();
         }
         /* set up parser */
         $this->_parser->set(array('memberData' => array('member_id' => $post['member_id'], 'member_group_id' => $post['member_group_id'], 'mgroup_others' => $post['mgroup_others']), 'parseBBCode' => $forumData['use_ibc'], 'parseHtml' => ($forumData['use_html'] and $poster['g_dohtml'] and $post['post_htmlstate']) ? 1 : 0, 'parseEmoticons' => $post['use_emo'], 'parseArea' => 'topics'));
         $post['post'] = $this->_parser->display($post['post']);
         IPSDebug::setMemoryDebugFlag("topics::parsePostRow - bbcode parse - Completed", $_NOW2);
         IPSContentCache::update($post['pid'], 'post', $post['post']);
     } else {
         $post['post'] = '<!--cached-' . gmdate('r', $post['cache_updated']) . '-->' . $post['cache_content'];
     }
     /* Buttons */
     $post['_can_delete'] = $post['pid'] != $topicData['topic_firstpost'] ? $this->canDeletePost($post) : FALSE;
     $post['_can_edit'] = $this->canEditPost($post);
     $post['_show_ip'] = $this->canSeeIp();
     $post['_canReply'] = $this->getReplyStatus() == 'reply' ? true : false;
     /* Signatures */
     $post['signature'] = "";
     if (!empty($poster['signature'])) {
         if ($post['use_sig'] == 1) {
             if (!$this->memberData['view_sigs'] || $poster['author_id'] && $this->memberData['member_id'] && !empty($this->member->ignored_users[$poster['author_id']]['ignore_signatures']) && IPSMember::isIgnorable($poster['member_group_id'], $poster['mgroup_others'])) {
                 $post['signature'] = '<!--signature.hidden.' . $post['pid'] . '-->';
             } else {
                 $post['signature'] = $this->registry->output->getTemplate('global')->signature_separator($poster['signature'], $poster['author_id'], IPSMember::isIgnorable($poster['member_group_id'], $poster['mgroup_others']));
             }
         }
     }
     $post['forum_id'] = $topicData['forum_id'];
     /* Reputation */
     if ($this->settings['reputation_enabled'] and !$this->isArchived($topicData)) {
         /* Load the class */
         if (!$this->registry->isClassLoaded('repCache')) {
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache');
             $this->registry->setClass('repCache', new $classToLoad());
         }
         $this->memberData['_members_cache']['rep_filter'] = isset($this->memberData['_members_cache']['rep_filter']) ? $this->memberData['_members_cache']['rep_filter'] : '*';
         $post['pp_reputation_points'] = $post['pp_reputation_points'] ? $post['pp_reputation_points'] : 0;
         $post['has_given_rep'] = $post['has_given_rep'] ? $post['has_given_rep'] : 0;
         $post['rep_points'] = $this->registry->repCache->getRepPoints(array('app' => 'forums', 'type' => 'pid', 'type_id' => $post['pid'], 'rep_points' => $post['rep_points']));
         $post['_repignored'] = 0;
         if (!($this->settings['reputation_protected_groups'] && in_array($this->memberData['member_group_id'], explode(',', $this->settings['reputation_protected_groups']))) && $this->memberData['_members_cache']['rep_filter'] !== '*') {
             if ($this->settings['reputation_show_content'] && $post['rep_points'] < $this->memberData['_members_cache']['rep_filter'] && $this->settings['reputation_point_types'] != 'like') {
                 $post['_repignored'] = 1;
             }
         }
         if ($this->registry->repCache->isLikeMode()) {
             $post['like'] = $this->registry->repCache->getLikeFormatted(array('app' => 'forums', 'type' => 'pid', 'id' => $post['pid'], 'rep_like_cache' => $post['rep_like_cache']));
         }
     }
     /* Ignore stuff */
     $post['_ignored'] = 0;
     if ($post['author_id'] && isset($topicData['ignoredUsers']) && is_array($topicData['ignoredUsers']) && count($topicData['ignoredUsers'])) {
         if (in_array($post['author_id'], $topicData['ignoredUsers'])) {
             if (!strstr($this->settings['cannot_ignore_groups'], ',' . $post['member_group_id'] . ',')) {
                 $post['_ignored'] = 1;
             }
         }
     }
     /* AD Code */
     $post['_adCode'] = '';
     if ($this->registry->getClass('IPSAdCode')->userCanViewAds() && !$this->getTopicData('adCodeSet') && !IPS_IS_AJAX) {
         $post['_adCode'] = $this->registry->getClass('IPSAdCode')->getAdCode('ad_code_topic_view_code');
         if ($post['_adCode']) {
             $this->setTopicData('adCodeSet', true);
         }
     }
     /* Memory debug */
     IPSDebug::setMemoryDebugFlag("PID: " . $post['pid'] . " - Completed", $_NOW);
     /* Excerpt */
     $post['_excerpt'] = IPSText::truncate(str_replace(array('<br />', '<br>', "\n", '</p>', '<p>'), ' ', $post['post']), 500);
     return array('post' => $post, 'author' => $poster);
 }
示例#15
0
 /**
  * Constructor :: Authorizes the session
  *
  * @param	boolean		$noAutoParsingSessions		No auto parsing of sessions - set as true when using API-like methods
  * @return	@e mixed	Void normally, but can print error message
  */
 public function __construct($noAutoParsingSessions = false)
 {
     /* Make object */
     $this->registry = ipsRegistry::instance();
     $this->DB = $this->registry->DB();
     $this->settings =& $this->registry->fetchSettings();
     $this->request =& $this->registry->fetchRequest();
     $this->cache = $this->registry->cache();
     $this->caches =& $this->registry->cache()->fetchCaches();
     $this->_member = self::instance();
     $this->_memberData =& self::instance()->fetchMemberData();
     /* Delete immediately */
     $this->_deleteNow = true;
     /**
      * If the sso.php file is present in this folder, we'll load it.
      * This file can be used to easily integrate single-sign on in
      * situations where you need to check session data
      */
     if (is_file(IPS_ROOT_PATH . '/sources/classes/session/sso.php')) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/classes/session/sso.php', 'ssoSessionExtension');
         if (class_exists($classToLoad)) {
             $this->sso = new $classToLoad($this->registry);
         }
     }
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $cookie = array();
     $this->_userAgent = substr($this->_member->user_agent, 0, 200);
     //-----------------------------------------
     // Fix up app / section / module
     //-----------------------------------------
     $this->current_appcomponent = IPS_APP_COMPONENT;
     $this->current_module = IPSText::alphanumericalClean($this->request['module']);
     $this->current_section = IPSText::alphanumericalClean($this->request['section']);
     $this->settings['session_expiration'] = $this->settings['session_expiration'] ? $this->settings['session_expiration'] : 3600;
     //-----------------------------------------
     // Return as guest if running a task
     //-----------------------------------------
     if (IPS_IS_TASK) {
         self::$data_store = IPSMember::setUpGuest();
         self::$data_store['last_activity'] = time();
         self::$data_store['last_visit'] = time();
         return true;
     }
     /* Not auto parsing sessions? */
     if ($noAutoParsingSessions === true) {
         return true;
     }
     //-----------------------------------------
     // no new headers if we're simply viewing an attachment..
     //-----------------------------------------
     if ($this->request['section'] == 'attach') {
         $this->settings['no_print_header'] = 1;
     }
     //-----------------------------------------
     // no new headers if we're updating chat
     //-----------------------------------------
     if (IPS_IS_AJAX && ($this->request['section'] != 'login' && $this->request['section'] != 'skin') or $this->request['section'] == 'attach' or $this->request['section'] == 'captcha') {
         $this->settings['no_print_header'] = 1;
         $this->do_update = 0;
     }
     //-----------------------------------------
     // IPS Connect
     //-----------------------------------------
     $ipsConnectEnabled = FALSE;
     foreach ($this->caches['login_methods'] as $k => $data) {
         if ($data['login_folder_name'] == 'ipsconnect' and $data['login_enabled']) {
             $ipsConnectEnabled = TRUE;
             $ipsConnectSettings = unserialize($data['login_custom_config']);
         }
     }
     //-----------------------------------------
     // Continue!
     //-----------------------------------------
     $cookie['session_id'] = IPSCookie::get('session_id');
     $cookie['member_id'] = IPSCookie::get('member_id');
     $cookie['pass_hash'] = IPSCookie::get('pass_hash');
     if ($cookie['session_id'] && empty($this->request['_nsc'])) {
         $this->getSession($cookie['session_id']);
         $this->session_type = 'cookie';
     } elseif (!empty($this->request['s'])) {
         $this->getSession($this->request['s']);
         $this->session_type = 'url';
     } else {
         $this->session_id = 0;
         $this->session_type = 'url';
     }
     //-----------------------------------------
     // Do we have a valid session ID?
     //-----------------------------------------
     if ($this->session_id) {
         $haveMember = FALSE;
         $forceNoMember = FALSE;
         /* Check we're not specifically logged out of IPS Connect */
         if ($ipsConnectEnabled and isset($_COOKIE['ipsconnect_' . md5($ipsConnectSettings['master_url'])]) and !$_COOKIE['ipsconnect_' . md5($ipsConnectSettings['master_url'])]) {
             $forceNoMember = TRUE;
         }
         /* Check Local */
         if (!empty($this->session_user_id) and !$forceNoMember) {
             self::setMember($this->session_user_id);
             if (self::$data_store['member_id'] and self::$data_store['member_id'] != 0) {
                 $haveMember = TRUE;
             }
         }
         /* Check IPS Connect */
         if (!$haveMember and !$forceNoMember) {
             if ($ipsConnectEnabled and isset($_COOKIE['ipsconnect_' . md5($ipsConnectSettings['master_url'])])) {
                 if ($_COOKIE['ipsconnect_' . md5($ipsConnectSettings['master_url'])]) {
                     require_once IPS_KERNEL_PATH . 'classFileManagement.php';
                     $cfm = new classFileManagement();
                     $return = $cfm->getFileContents($ipsConnectSettings['master_url'] . '?' . http_build_query(array('act' => 'cookies', 'data' => json_encode($_COOKIE))));
                     if ($return = @json_decode($return, TRUE)) {
                         if ($return['connect_status'] == 'SUCCESS') {
                             $this->_handleIpsConnect($return);
                             $haveMember = TRUE;
                         }
                     }
                 }
             }
         }
         /* Handle */
         if ($haveMember) {
             $this->_updateMemberSession();
             /**
              * If we have an SSO object, run it for the update member call
              */
             if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForMember')) {
                 $this->sso->checkSSOForMember('update');
             }
         } else {
             $this->_updateGuestSession();
             /**
              * If we have an SSO object, run it for the update guest session call
              */
             if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForGuest')) {
                 $this->sso->checkSSOForGuest('update');
             }
         }
     } else {
         //-----------------------------------------
         // We didn't have a session, or the session didn't validate
         // Do we have cookies stored?
         //-----------------------------------------
         $haveMember = FALSE;
         if ($ipsConnectEnabled and isset($_COOKIE['ipsconnect_' . md5($ipsConnectSettings['master_url'])])) {
             if ($_COOKIE['ipsconnect_' . md5($ipsConnectSettings['master_url'])]) {
                 require_once IPS_KERNEL_PATH . 'classFileManagement.php';
                 $cfm = new classFileManagement();
                 $return = $cfm->getFileContents($ipsConnectSettings['master_url'] . '?' . http_build_query(array('act' => 'cookies', 'data' => json_encode($_COOKIE))));
                 if ($return = @json_decode($return, TRUE)) {
                     if ($return['connect_status'] == 'SUCCESS') {
                         $this->_handleIpsConnect($return);
                         $haveMember = TRUE;
                     }
                 }
             }
         } elseif ($cookie['member_id'] != "" and $cookie['pass_hash'] != "") {
             self::setMember($cookie['member_id']);
             if (self::$data_store['member_id'] and self::$data_store['member_login_key'] == $cookie['pass_hash'] and (!$this->settings['login_key_expire'] or time() <= self::$data_store['member_login_key_expire'])) {
                 $haveMember = TRUE;
             }
         }
         //-----------------------------------------
         // Handle
         //-----------------------------------------
         if ($haveMember) {
             $this->_createMemberSession();
             /**
              * If we have an SSO object, run it for the create member call
              */
             if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForMember')) {
                 $this->sso->checkSSOForMember('create');
             }
         } else {
             self::setMember(0);
             $this->_createGuestSession();
             /**
              * If we have an SSO object, run it for the create guest call
              */
             if (is_object($this->sso) and method_exists($this->sso, 'checkSSOForGuest')) {
                 $this->sso->checkSSOForGuest('create');
             }
         }
     }
     //-----------------------------------------
     // Knock out Google Web Accelerator
     //-----------------------------------------
     if (ipsRegistry::$settings['disable_prefetching']) {
         if (my_getenv('HTTP_X_MOZ') and strstr(strtolower(my_getenv('HTTP_X_MOZ')), 'prefetch') and self::$data_store['member_id']) {
             if (isset($_SERVER['SERVER_PROTOCOL']) and strstr($_SERVER['SERVER_PROTOCOL'], '/1.0')) {
                 @header('HTTP/1.0 403 Forbidden');
             } else {
                 @header('HTTP/1.1 403 Forbidden');
             }
             @header("Cache-Control: no-cache, must-revalidate, max-age=0");
             @header("Expires: 0");
             @header("Pragma: no-cache");
             print "Prefetching or precaching is not allowed. If you have Google Accelerator enabled, please disable";
             exit;
         }
     }
     //-----------------------------------------
     // Still no member id and not a bot?
     //-----------------------------------------
     if (empty(self::$data_store['member_id']) and !$this->_member->is_not_human) {
         self::setMember(0);
         self::$data_store['last_activity'] = time();
         $this->request['last_visit'] = time();
     }
     //-----------------------------------------
     // Set a session ID cookie
     //-----------------------------------------
     $this->_member->session_type = $this->session_type;
     $this->_member->session_id = $this->session_id;
     IPSCookie::set("session_id", $this->session_id, -1);
 }
示例#16
0
 /**
  * Set current member to the member ID specified
  *
  * @param	integer		Member ID
  * @return	@e void
  */
 public static function setMember($member_id)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $member_id = intval($member_id);
     $addrs = array();
     //-----------------------------------------
     // If we have a member ID, set up the member
     //-----------------------------------------
     if ($member_id) {
         self::$data_store = IPSMember::load($member_id, 'extendedProfile,customFields,groups');
     }
     /* Got a member ID? */
     if (!empty($member_id) && self::$data_store['member_id']) {
         self::setUpMember();
         self::instance()->language_id = self::$data_store['language'];
         # Form hash
         self::instance()->form_hash = md5(self::$data_store['email'] . '&' . self::$data_store['member_login_key'] . '&' . self::$data_store['joined']);
     } else {
         self::$data_store = IPSMember::setUpGuest();
         self::instance()->perm_id = !empty(self::$data_store['org_perm_id']) ? self::$data_store['org_perm_id'] : self::$data_store['g_perm_id'];
         self::instance()->perm_id_array = explode(',', self::instance()->perm_id);
         if (IPSCookie::get('language')) {
             self::instance()->language_id = IPSCookie::get('language');
         }
         # Form hash
         self::instance()->form_hash = md5("this is only here to prevent it breaking on guests");
     }
     /* Get the ignored users */
     if (IPS_AREA == 'public') {
         /* Ok, Fetch ignored users */
         self::instance()->ignored_users = IPSMember::fetchIgnoredUsers(self::$data_store);
     }
     //-----------------------------------------
     // Set member data
     //-----------------------------------------
     self::instance()->member_id = $member_id;
 }
 /**
  * Builds comments
  *
  * @access	public
  * @param	array 		Member information
  * @param	boolean		Use a new id
  * @param	string		Message to display
  * @return	string		Comment HTML
  * @since	IPB 2.2.0.2006-08-02
  */
 public function buildComments($member, $new_id = 0, $return_msg = '')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $comments = array();
     $member_id = intval($member['member_id']);
     $comment_perpage = 15;
     //intval( $member['pp_setting_count_comments'] );
     $comment_html = 0;
     $comment_start = intval($this->request['st']);
     $comment_approved = ($this->memberData['member_id'] == $member['member_id'] or $this->memberData['g_is_supmod']) ? '' : ' AND ( pc.comment_approved=1 OR ( pc.comment_approved=0 AND pc.comment_by_member_id=' . $member_id . ') )';
     //-----------------------------------------
     // Not showing comments?
     //-----------------------------------------
     if ($comment_perpage < 1) {
         return '';
     }
     //-----------------------------------------
     // Regenerate comments...
     //-----------------------------------------
     $this->DB->build(array('select' => 'pc.*', 'from' => array('profile_comments' => 'pc'), 'where' => 'pc.comment_for_member_id=' . $member_id . $comment_approved, 'order' => 'pc.comment_date DESC', 'limit' => array($comment_start, $comment_perpage), 'calcRows' => TRUE, 'add_join' => array(array('select' => 'm.members_display_name, m.members_seo_name, m.posts, m.last_activity, m.member_group_id, m.member_id, m.last_visit, m.warn_level', 'from' => array('members' => 'm'), 'where' => 'm.member_id=pc.comment_by_member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'))));
     $o = $this->DB->execute();
     $max = $this->DB->fetchCalculatedRows();
     while ($row = $this->DB->fetch($o)) {
         $row['_comment_date'] = ipsRegistry::getClass('class_localization')->getDate($row['comment_date'], 'TINY');
         $row = IPSMember::buildDisplayData($row);
         if (!$row['members_display_name_short']) {
             $row = array_merge($row, IPSMember::setUpGuest());
         }
         $comments[] = $row;
     }
     //-----------------------------------------
     // Pagination
     //-----------------------------------------
     $links = $this->registry->output->generatePagination(array('totalItems' => $max, 'itemsPerPage' => $comment_perpage, 'currentStartValue' => $comment_start, 'baseUrl' => "showuser={$member_id}", 'seoTitle' => $member['members_seo_name']));
     $comment_html = $this->registry->getClass('output')->getTemplate('profile')->showComments($member, $comments, $new_id, $return_msg, $links);
     //-----------------------------------------
     // Return it...
     //-----------------------------------------
     return $comment_html;
 }
 /**
  * Returns a complete topic
  *
  * @access	public
  * @param	int 		Member ID
  * @param	string		Folder ID (eg: inbox, sent, etc)
  * @param	array 		Array of data ( array[ sort => '', offsetStart' => '', 'offsetEnd' => '' )
  * @return	array 		Array of PMs indexed by PM ID
  *
  * <code>
  * Exception Codes
  * NO_READ_PERMISSION		You do not have permission to read the topic
  * YOU_ARE_BANNED			You have been banned
  * </code>
  */
 public function fetchConversation($topicID, $readingMemberID, $filters = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $readingMemberID = intval($readingMemberID);
     $topicID = intval($topicID);
     $oStart = intval($filters['offsetStart']);
     $oEnd = intval($filters['offsetEnd']);
     $replyData = array();
     $topicData = array();
     $remapData = array();
     $memberData = array();
     $missingMembers = array();
     $whereExtra = '';
     //-----------------------------------------
     // Figure out sort key
     //-----------------------------------------
     switch ($filters['sort']) {
         case 'rdate':
             $sortKey = 'msg.msg_date DESC';
             break;
         default:
             $sortKey = 'msg.msg_date ASC';
             break;
     }
     if (!$topicID) {
         return array('topicData' => $topicData, 'replyData' => $replyData);
     } else {
         /* Get member data */
         $memberData = $this->fetchTopicParticipants($topicID, TRUE);
         /* Get reading member's data */
         $readingMemberData = $memberData[$readingMemberID];
         /* Fetch topic data */
         $topicData = $this->fetchTopicData($topicID, FALSE);
         /* Topic deleted? Grab topic starter details, as they won't be in the participant array */
         if ($topicData['mt_is_deleted'] and $topicData['mt_starter_id'] > 0) {
             $memberData[$topicData['mt_starter_id']] = IPSMember::load($topicData['mt_starter_id'], 'all');
             $memberData[$topicData['mt_starter_id']]['_canBeBlocked'] = IPSMember::isIgnorable($memberData[$topicData['mt_starter_id']]['member_group_id'], $memberData[$topicData['mt_starter_id']]['mgroup_others']);
             $memberData[$topicData['mt_starter_id']] = IPSMember::buildDisplayData($memberData[$topicData['mt_starter_id']], array('__all__' => 1));
             $memberData[$topicData['mt_starter_id']]['map_user_active'] = 1;
             /* Set flag for topic participant starter */
             $memberData[$topicData['mt_starter_id']]['map_is_starter'] = 1;
             foreach ($memberData as $id => $data) {
                 $memberData[$id]['_topicDeleted'] = 1;
             }
         }
         /* Can access this topic? */
         if ($this->canAccessTopic($readingMemberID, $topicData, $memberData) !== TRUE) {
             /* Banned? */
             if ($readingMemberData['map_user_banned']) {
                 throw new Exception("YOU_ARE_BANNED");
             } else {
                 throw new Exception("NO_READ_PERMISSION");
             }
         }
         /* Reply Data */
         $this->DB->build(array('select' => 'msg.*', 'from' => array('message_posts' => 'msg'), 'where' => "msg.msg_topic_id=" . $topicID . $whereExtra, 'order' => $sortKey, 'limit' => array($oStart, $oEnd), 'add_join' => array(array('select' => 'iu.*', 'from' => array('ignored_users' => 'iu'), 'where' => 'iu.ignore_owner_id=' . $readingMemberID . ' AND iu.ignore_ignore_id=msg.msg_author_id', 'type' => 'left'), array('select' => 'm.member_group_id, m.mgroup_others', 'from' => array('members' => 'm'), 'where' => 'm.member_id=msg.msg_author_id', 'type' => 'left'))));
         $o = $this->DB->execute();
         //-----------------------------------------
         // Get the messages
         //-----------------------------------------
         while ($msg = $this->DB->fetch($o)) {
             $msg['_ip_address'] = "";
             /* IP Address */
             if ($msg['msg_ip_address'] and $readingMemberData['g_is_supmod'] == 1) {
                 $msg['_ip_address'] = $msg['msg_ip_address'];
             }
             /* Edit */
             $msg['_canEdit'] = $this->_conversationCanEdit($msg, $topicData, $readingMemberData);
             /* Delete */
             $msg['_canDelete'] = $this->_conversationCanDelete($msg, $topicData, $readingMemberData);
             /* Format Message */
             $msg['msg_post'] = $this->_formatMessageForDisplay($msg['msg_post'], $msg);
             /* Member missing? */
             if (!isset($memberData[$msg['msg_author_id']])) {
                 $missingMembers[$msg['msg_author_id']] = $msg['msg_author_id'];
             }
             $replyData[$msg['msg_id']] = $msg;
         }
     }
     /* Members who've deleted a closed conversation? */
     if (count($missingMembers)) {
         $_members = IPSMember::load(array_keys($missingMembers), 'all');
         foreach ($_members as $id => $data) {
             $data['_canBeBlocked'] = IPSMember::isIgnorable($memberData[$topicData['mt_starter_id']]['member_group_id'], $memberData[$topicData['mt_starter_id']]['mgroup_others']);
             $data['map_user_active'] = 0;
             $memberData[$data['member_id']] = IPSMember::buildDisplayData($data, array('__all__' => 1));
         }
     }
     /* Update reading member's read time */
     $this->DB->update('message_topic_user_map', array('map_read_time' => time(), 'map_has_unread' => 0), 'map_user_id=' . intval($readingMemberData['member_id']) . ' AND map_topic_id=' . $topicID);
     /* Reduce the number of 'new' messages */
     $_newMsgs = intval($this->getPersonalTopicsCount($readingMemberID, 'new'));
     if ($memberData[$readingMemberID]['map_has_unread']) {
         $_pc = $this->rebuildFolderCount($readingMemberID, array('new' => $_newMsgs), TRUE);
         IPSMember::save($readingMemberID, array('core' => array('msg_count_new' => $_newMsgs)));
         /* is this us? */
         if ($readingMemberID == $this->memberData['member_id']) {
             /* Reset folder data */
             $this->_dirData = $this->explodeFolderData($_pc);
             /* Reset global new count */
             $this->memberData['msg_count_new'] = $_newMsgs;
         }
     }
     /* Clean up topic title */
     $topicData['mt_title'] = str_replace('[attachmentid=', '&#91;attachmentid=', $topicData['mt_title']);
     /* Ensure our read time is updated */
     $memberData[$readingMemberID]['map_read_time'] = time();
     /* Do we  have a deleted user? */
     if (isset($memberData[0]) and $memberData[0]['member_id'] == 0) {
         $memberData[0] = IPSMember::buildDisplayData(IPSMember::setUpGuest("Deleted Member"), array('__all__' => 1));
     }
     //-----------------------------------------
     // Attachments?
     //-----------------------------------------
     if ($topicData['mt_hasattach']) {
         //-----------------------------------------
         // INIT. Yes it is
         //-----------------------------------------
         $postHTML = array();
         //-----------------------------------------
         // Separate out post content
         //-----------------------------------------
         foreach ($replyData as $id => $post) {
             $postHTML[$id] = $post['msg_post'];
         }
         if (!is_object($this->class_attach)) {
             require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php';
             $this->class_attach = new class_attach($this->registry);
         }
         $this->class_attach->type = 'msg';
         $this->class_attach->init();
         $attachHTML = $this->class_attach->renderAttachments($postHTML);
         /* Now parse back in the rendered posts */
         foreach ($attachHTML as $id => $data) {
             /* Get rid of any lingering attachment tags */
             if (stristr($data['html'], "[attachment=")) {
                 $data['html'] = IPSText::stripAttachTag($data['html']);
             }
             $replyData[$id]['msg_post'] = $data['html'];
             $replyData[$id]['attachmentHtml'] = $data['attachmentHtml'];
         }
     }
     /* Return */
     return array('topicData' => $topicData, 'replyData' => $replyData, 'memberData' => $memberData);
 }
示例#19
0
 /**
  * Fetch data tagged the same
  * @return array
  */
 protected function _getSameTaggedData()
 {
     /* Init */
     $topicData = $this->registry->getClass('topics')->getTopicData();
     $results = array();
     $final = array();
     /* Have we got tags? */
     if ($this->settings['forums_enabled_also_tagged'] && $this->settings['tags_enabled'] && count($topicData['tags']['tags'])) {
         $results = $this->registry->tags->search($topicData['tags']['tags'], array('meta_app' => 'forums', 'meta_area' => 'topics', 'meta_parent_id' => false, 'not_meta_id' => $topicData['tid'], 'sortKey' => 'tg.tag_meta_id', 'sortOrder' => 'desc', 'limit' => 100, 'joins' => array(array('select' => 't.*, t.approved, t.title as topic_title, t.posts as topic_posts, t.last_post as topic_last_post', 'from' => array('topics' => 't'), 'where' => 't.tid=tg.tag_meta_id'), array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'last_poster_id=m.member_id'), array('select' => 'p.*', 'from' => array('profile_portal' => 'p'), 'where' => 'p.pp_member_id=m.member_id'), $this->registry->tags->getCacheJoin(array('meta_id_field' => 't.tid'))), 'isViewable' => true));
     }
     /* Limit to 5 unique topics */
     if (is_array($results) and count($results)) {
         $_tmp = $results;
         $results = array();
         $loadIds = array();
         $members = array();
         foreach ($_tmp as $_id => $_data) {
             if (!isset($results[$_data['tid']])) {
                 if ($this->registry->class_forums->fetchHiddenTopicType($_data) != 'visible') {
                     continue;
                 }
                 if (!$this->registry->permissions->check('view', $this->registry->class_forums->forum_by_id[$_data['forum_id']])) {
                     continue;
                 }
                 if (!$this->registry->class_forums->forumsCheckAccess($_data['forum_id'], 0, 'forum', array(), true)) {
                     continue;
                 }
                 if ($_data['starter_id']) {
                     $loadIds[$_data['starter_id']] = $_data['starter_id'];
                 }
                 $results[$_data['tid']] = $_data;
                 /* Alreay got our 5 results? */
                 if (count($results) == 5) {
                     break;
                 }
             }
         }
         if (count($loadIds)) {
             $members = IPSMember::load($loadIds);
         }
         /* Finally parse our results */
         foreach ($results as $id => $data) {
             if ($data['starter_id'] && isset($members[$data['starter_id']])) {
                 $data['_starter'] = IPSMember::buildDisplayData($members[$data['starter_id']]);
             } else {
                 $data['_starter'] = IPSMember::buildDisplayData(IPSMember::setUpGuest($data['starter_name'] ? $this->settings['guest_name_pre'] . $data['starter_name'] . $this->settings['guest_name_suf'] : ''));
             }
             $data = $this->registry->topics->parseTopicForLineEntry($data);
             /* Sort out navigation */
             $data['nav'] = $this->registry->class_forums->forumsBreadcrumbNav($data['forum_id']);
             if ($data['last_poster_id']) {
                 $final[$data['tid']] = IPSMember::buildDisplayData($data, array('photoTagSize' => 'mini'));
             } else {
                 $final[$data['tid']] = $data;
             }
         }
     }
     return $final;
 }
示例#20
0
 /**
  * Various getters and setters
  *
  * @param	string
  * @param	mixed		void, or an array of arguments
  * @return	mixed		Data
  */
 public function __call($method, $arguments)
 {
     $firstBit = substr($method, 0, 3);
     $theRest = substr($method, 3);
     if (in_array($theRest, $this->_allowedInternalData)) {
         if ($firstBit == 'set') {
             if ($theRest == 'Author' or $theRest == 'Friend') {
                 if (is_array($arguments[0])) {
                     /* Ensure we have group data */
                     if (!isset($arguments[0]['g_id']) and $arguments[0]['member_id']) {
                         $this->_internalData[$theRest] = IPSMember::load(intval($arguments[0]['member_id']), 'all');
                     } else {
                         $this->_internalData[$theRest] = $arguments[0];
                     }
                 } else {
                     if ($arguments[0]) {
                         /* Set up moderator stuff, too */
                         $this->_internalData[$theRest] = IPSMember::load(intval($arguments[0]), 'all');
                     } else {
                         $this->_internalData[$theRest] = IPSMember::setUpGuest();
                     }
                 }
             } else {
                 if ($theRest == 'StatusData') {
                     if (is_array($arguments[0])) {
                         $this->_internalData[$theRest] = $arguments[0];
                     } else {
                         $this->_internalData[$theRest] = $this->_loadStatus(intval($arguments[0]));
                     }
                 } else {
                     if ($theRest == 'ReplyData') {
                         if (is_array($arguments[0])) {
                             $this->_internalData[$theRest] = $arguments[0];
                         } else {
                             $this->_internalData[$theRest] = $this->_loadReply(intval($arguments[0]));
                         }
                     } else {
                         $this->_internalData[$theRest] = $arguments[0];
                         return TRUE;
                     }
                 }
             }
             return $this->_internalData[$theRest];
         } else {
             if (($theRest == 'Author' or $theRest == 'Friend' or $theRest == 'StatusData' or $theRest == 'ReplyData') and isset($arguments[0])) {
                 return isset($this->_internalData[$theRest][$arguments[0]]) ? $this->_internalData[$theRest][$arguments[0]] : '';
             } else {
                 return isset($this->_internalData[$theRest]) ? $this->_internalData[$theRest] : '';
             }
         }
     }
 }
 /**
  * Builds an array of post data for output
  *
  * @access	public
  * @param	array	$row	Array of post data
  * @return	array
  **/
 public function parsePostRow($row = array())
 {
     //-----------------------------------------
     // Memory Debug
     //-----------------------------------------
     $_NOW = IPSDebug::getMemoryDebugFlag();
     $poster = array();
     //-----------------------------------------
     // Cache member
     //-----------------------------------------
     if ($row['author_id'] != 0) {
         //-----------------------------------------
         // Is it in the hash?
         //-----------------------------------------
         if (isset($this->cached_members[$row['author_id']])) {
             //-----------------------------------------
             // Ok, it's already cached, read from it
             //-----------------------------------------
             $poster = $this->cached_members[$row['author_id']];
             $row['name_css'] = 'normalname';
         } else {
             $row['name_css'] = 'normalname';
             $poster = $row;
             if (isset($poster['cache_content_sig'])) {
                 $poster['cache_content'] = $poster['cache_content_sig'];
                 $poster['cache_updated'] = $poster['cache_updated_sig'];
                 /* Cache data monitor */
                 $this->_cacheMonitor['sig']['cached']++;
             } else {
                 unset($poster['cache_content'], $poster['cache_updated']);
                 /* Cache data monitor */
                 $this->_cacheMonitor['sig']['raw']++;
             }
             $poster = IPSMember::buildDisplayData($poster, array('signature' => 1, 'customFields' => 1, 'warn' => 1, 'avatar' => 1, 'checkFormat' => 1, 'cfLocation' => 'topic'));
             $poster['member_id'] = $row['mid'];
             //-----------------------------------------
             // Add it to the cached list
             //-----------------------------------------
             $this->cached_members[$row['author_id']] = $poster;
         }
     } else {
         //-----------------------------------------
         // It's definitely a guest...
         //-----------------------------------------
         $row['author_name'] = $this->settings['guest_name_pre'] . $row['author_name'] . $this->settings['guest_name_suf'];
         $poster = IPSMember::setUpGuest($row['author_name']);
         $poster['members_display_name'] = $row['author_name'];
         $poster['_members_display_name'] = $row['author_name'];
         $poster['custom_fields'] = "";
         $poster['warn_img'] = "";
         $row['name_css'] = 'unreg';
     }
     # Memory Debug
     IPSDebug::setMemoryDebugFlag("PID: " . $row['pid'] . " - Member Parsed", $_NOW);
     //-----------------------------------------
     // Queued
     //-----------------------------------------
     if ($this->topic['topic_firstpost'] == $row['pid'] and $this->topic['approved'] != 1) {
         $row['queued'] = 1;
     }
     //-----------------------------------------
     // Edit...
     //-----------------------------------------
     $row['edit_by'] = "";
     if ($row['append_edit'] == 1 and $row['edit_time'] != "" and $row['edit_name'] != "") {
         $e_time = $this->registry->class_localization->getDate($row['edit_time'], 'LONG');
         $row['edit_by'] = sprintf($this->lang->words['edited_by'], $row['edit_name'], $e_time);
     }
     //-----------------------------------------
     // Parse the post
     //-----------------------------------------
     if (!$row['cache_content']) {
         $_NOW2 = IPSDebug::getMemoryDebugFlag();
         IPSText::getTextClass('bbcode')->parse_smilies = $row['use_emo'];
         IPSText::getTextClass('bbcode')->parse_html = ($this->forum['use_html'] and $this->caches['group_cache'][$row['member_group_id']]['g_dohtml'] and $row['post_htmlstate']) ? 1 : 0;
         IPSText::getTextClass('bbcode')->parse_nl2br = $row['post_htmlstate'] == 2 ? 1 : 0;
         IPSText::getTextClass('bbcode')->parse_bbcode = $this->forum['use_ibc'];
         IPSText::getTextClass('bbcode')->parsing_section = 'topics';
         IPSText::getTextClass('bbcode')->parsing_mgroup = $row['member_group_id'];
         IPSText::getTextClass('bbcode')->parsing_mgroup_others = $row['mgroup_others'];
         /* Work around */
         $_tmp = $this->memberData['view_img'];
         $this->memberData['view_img'] = 1;
         $row['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($row['post']);
         $this->memberData['view_img'] = $_tmp;
         IPSDebug::setMemoryDebugFlag("topics::parsePostRow - bbcode parse - Completed", $_NOW2);
         IPSContentCache::update($row['pid'], 'post', $row['post']);
         /* Cache data monitor */
         $this->_cacheMonitor['post']['raw']++;
     } else {
         $row['post'] = '<!--cached-' . gmdate('r', $row['cache_updated']) . '-->' . $row['cache_content'];
         /* Cache data monitor */
         $this->_cacheMonitor['post']['cached']++;
     }
     //-----------------------------------------
     // Capture content
     //-----------------------------------------
     if ($this->topic['topic_firstpost'] == $row['pid']) {
         $this->_firstPostContent = $row['post'];
     }
     //-----------------------------------------
     // View image...
     //-----------------------------------------
     $row['post'] = IPSText::getTextClass('bbcode')->memberViewImages($row['post']);
     //-----------------------------------------
     // Highlight...
     //-----------------------------------------
     if ($this->request['hl']) {
         $row['post'] = IPSText::searchHighlight($row['post'], $this->request['hl']);
     }
     //-----------------------------------------
     // Multi Quoting?
     //-----------------------------------------
     if ($this->qpids) {
         if (strstr(',' . $this->qpids . ',', ',' . $row['pid'] . ',')) {
             $row['_mq_selected'] = 1;
         }
     }
     //-----------------------------------------
     // Multi PIDS?
     //-----------------------------------------
     if ($this->memberData['is_mod']) {
         if ($this->request['selectedpids']) {
             if (strstr(',' . $this->request['selectedpids'] . ',', ',' . $row['pid'] . ',')) {
                 $row['_pid_selected'] = 1;
             }
             $this->request['selectedpidcount'] = count(explode(",", $this->request['selectedpids']));
         }
     }
     //-----------------------------------------
     // Delete button..
     //-----------------------------------------
     $row['_can_delete'] = $row['pid'] != $this->topic['topic_firstpost'] ? $this->_getDeleteButtonData($row) : FALSE;
     $row['_can_edit'] = $this->_getEditButtonData($row);
     $row['_show_ip'] = $this->_getIPAddressData();
     //-----------------------------------------
     // Siggie stuff
     //-----------------------------------------
     $row['signature'] = "";
     if (isset($poster['signature']) and $poster['signature'] and $this->memberData['view_sigs']) {
         if ($row['use_sig'] == 1) {
             $row['signature'] = $this->registry->output->getTemplate('global')->signature_separator($poster['signature']);
         }
     }
     //-----------------------------------------
     // Fix up the membername so it links to the members profile
     //-----------------------------------------
     if ($poster['member_id']) {
         $poster['_members_display_name'] = "<a href='{$this->settings['_base_url']}showuser={$poster['member_id']}'>{$poster['members_display_name_short']}</a>";
     }
     //-----------------------------------------
     // Post number
     //-----------------------------------------
     if ($this->topic_view_mode == 'linearplus' and $this->topic['topic_firstpost'] == $row['pid']) {
         $row['post_count'] = 1;
         if (!$this->first) {
             $this->post_count++;
         }
     } else {
         $this->post_count++;
         $row['post_count'] = intval($this->request['st']) + $this->post_count;
     }
     $row['forum_id'] = $this->topic['forum_id'];
     //-----------------------------------------
     // Memory Debug
     //-----------------------------------------
     IPSDebug::setMemoryDebugFlag("PID: " . $row['pid'] . " - Completed", $_NOW);
     return array('row' => $row, 'poster' => $poster);
 }
示例#22
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);
 }
示例#23
0
 /**
  * Process Results
  *
  * @param	array	Row from database using query specified in fetch()
  * @return	array	Same data with any additional processing necessary
  */
 public function process($row)
 {
     if (empty($row['comment_id'])) {
         $idField = 'event_id';
         $authorField = 'event_member_id';
         $contentField = 'event_content';
         $parseSmilies = intval($row['event_smilies']);
     } else {
         $idField = 'comment_id';
         $authorField = 'comment_mid';
         $contentField = 'comment_text';
         $parseSmilies = 1;
     }
     /* Build poster's display data */
     $member = $row[$authorField] ? IPSMember::load($row[$authorField], 'profile_portal,pfields_content,sessions,groups', 'id') : IPSMember::setUpGuest();
     $row = array_merge($row, IPSMember::buildDisplayData($member, array('reputation' => 0, 'warn' => 0)));
     /* Parse BBCode */
     IPSText::getTextClass('bbcode')->parse_smilies = $parseSmilies;
     IPSText::getTextClass('bbcode')->parse_html = 0;
     IPSText::getTextClass('bbcode')->parse_nl2br = 1;
     IPSText::getTextClass('bbcode')->parse_bbcode = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'calendar';
     IPSText::getTextClass('bbcode')->parsing_mgroup = $member['member_group_id'];
     IPSText::getTextClass('bbcode')->parsing_mgroup_others = $member['mgroup_others'];
     $row[$contentField] = IPSText::getTextClass('bbcode')->preDisplayParse($row[$contentField]);
     /* Parse attachments */
     $messageHTML = array($row[$idField] => $row[$contentField]);
     $attachHTML = $this->class_attach->renderAttachments($messageHTML, array($row[$idField]));
     if (is_array($attachHTML) and count($attachHTML)) {
         /* Get rid of any lingering attachment tags */
         if (stristr($attachHTML[$row[$idField]]['html'], "[attachment=")) {
             $attachHTML[$row[$idField]]['html'] = IPSText::stripAttachTag($attachHTML[$row[$idField]]['html']);
         }
         $row[$contentField] = $attachHTML[$row[$idField]]['html'] . $attachHTML[$row[$idField]]['attachmentHtml'];
     }
     /* Get rep buttons */
     if ($row['repUserGiving'] == ipsRegistry::member()->getProperty('member_id')) {
         $row['has_given_rep'] = $row['rep_rating'];
     }
     $row['repButtons'] = ipsRegistry::getClass('repCache')->getLikeFormatted(array('app' => 'calendar', 'type' => $idField, 'id' => $row[$idField], 'rep_like_cache' => $row['rep_like_cache']));
     /* Return */
     return $row;
 }