示例#1
0
 /**
  * Edit a post
  *
  * Usage:
  * $post->setForumID(1);
  * $post->setTopicID(5);
  * $post->setPostID(100);
  * $post->setAuthor( $member );
  * 
  * $post->setPostContent( "Hello [b]there![/b]" );
  * # Optional: No bbcode, etc parsing will take place
  * # $post->setPostContentPreFormatted( "Hello <b>there!</b>" );
  * $post->editPost();
  *
  * Exception Error Codes:
  * NO_POSTING_PPD       : No post ID set
  * NO_CONTENT        : No post content set
  * CONTENT_TOO_LONG  : Post is too long
  *
  * @return	mixed
  */
 public function editPost()
 {
     //-----------------------------------------
     // Global checks and functions
     //-----------------------------------------
     try {
         $this->globalSetUp();
     } catch (Exception $error) {
         $e = $error->getMessage();
         if ($e != 'NO_POSTING_PPD') {
             $this->_postErrors = $error->getMessage();
         }
     }
     if ($this->_bypassPermChecks !== TRUE && IPSMember::isOnModQueue($this->getAuthor()) === NULL) {
         $this->_postErrors = 'warnings_restrict_post_perm';
     }
     if (!$this->getPostContent() and !$this->getPostContentPreFormatted()) {
         $this->_postErrors = 'NO_CONTENT';
     }
     //-----------------------------------------
     // Get topic
     //-----------------------------------------
     try {
         $topic = $this->editSetUp();
     } catch (Exception $error) {
         $this->_postErrors = $error->getMessage();
     }
     //-----------------------------------------
     // Parse the post, and check for any errors.
     //-----------------------------------------
     $post = $this->compilePostData();
     //-----------------------------------------
     // Do we have a valid post?
     //-----------------------------------------
     if (strlen(trim(IPSText::removeControlCharacters(IPSText::br2nl($post['post'])))) < 1) {
         $this->_postErrors = 'NO_CONTENT';
     }
     if (IPSText::mbstrlen($post['post']) > $this->settings['max_post_length'] * 1024) {
         $this->_postErrors = 'CONTENT_TOO_LONG';
     }
     if ($this->_postErrors != "") {
         //-----------------------------------------
         // Show the form again
         //-----------------------------------------
         return FALSE;
     }
     //-----------------------------------------
     // Ajax specifics
     //-----------------------------------------
     if ($this->getIsAjax() === TRUE) {
         # Prevent polls from being edited
         $this->can_add_poll = 0;
         # Prevent titles from being edited
         $this->edit_title = 0;
         # Prevent open time from being edited
         $this->can_set_open_time = 0;
         # Prevent close time from being edited
         $this->can_set_close_time = 0;
         # Set Settings
         $this->setSettings(array('enableSignature' => $this->_originalPost['use_sig'] ? 1 : 0, 'enableEmoticons' => $this->_originalPost['use_emo'] ? 1 : 0, 'post_htmlstatus' => $this->getSettings('post_htmlstatus')));
         if (!$this->getAuthor('g_append_edit')) {
             $this->request['add_edit'] = ($this->_originalPost['append_edit'] or !$this->getAuthor('g_append_edit') ? 1 : 0);
         }
     }
     //-----------------------------------------
     // Compile the poll
     //-----------------------------------------
     if ($this->can_add_poll) {
         //-----------------------------------------
         // Load the poll from the DB
         //-----------------------------------------
         $this->poll_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'polls', 'where' => "tid=" . intval($topic['tid'])));
         $this->poll_answers = !empty($this->poll_data['choices']) && IPSLib::isSerialized($this->poll_data['choices']) ? IPSLib::safeUnserialize(stripslashes($this->poll_data['choices'])) : array();
     }
     //-----------------------------------------
     // Compile the poll
     //-----------------------------------------
     $this->poll_questions = $this->compilePollData();
     if ($this->_postErrors != "" or $this->getIsPreview() === TRUE) {
         //-----------------------------------------
         // Show the form again
         //-----------------------------------------
         return FALSE;
     }
     /* Got a topics table to update? */
     $updateTopicTable = array();
     //-----------------------------------------
     // Reset some data
     //-----------------------------------------
     $post['ip_address'] = $this->_originalPost['ip_address'];
     $post['topic_id'] = $this->_originalPost['topic_id'];
     $post['author_id'] = $this->_originalPost['author_id'];
     $post['post_date'] = $this->_originalPost['post_date'];
     $post['author_name'] = $this->_originalPost['author_name'];
     $post['queued'] = $this->_originalPost['queued'];
     $post['edit_time'] = $this->getDate() ? $this->getDate() : IPS_UNIX_TIME_NOW;
     $post['edit_name'] = $this->getAuthor('members_display_name');
     if ($this->_originalPost['new_topic'] == 1) {
         /* Tagging */
         if (isset($_POST['ipsTags'])) {
             $this->registry->tags->replace($_POST['ipsTags'], array('meta_id' => $topic['tid'], 'meta_parent_id' => $topic['forum_id'], 'member_id' => $this->memberData['member_id'], 'meta_visible' => $topic['approved']));
         }
         /* Like if not ajax edit */
         if (!IPS_IS_AJAX) {
             $this->addTopicToTracker($topic['tid']);
         }
         //-----------------------------------------
         // Update open and close times
         //-----------------------------------------
         if ($this->can_set_open_time and $this->times['open']) {
             $updateTopicTable['topic_open_time'] = intval($this->times['open']);
             if ($topic['topic_open_time'] and $this->times['open']) {
                 $updateTopicTable['state'] = 'closed';
                 if (IPS_UNIX_TIME_NOW > $topic['topic_open_time']) {
                     if (IPS_UNIX_TIME_NOW < $topic['topic_close_time']) {
                         $updateTopicTable['state'] = 'open';
                     }
                 }
             }
             if (!$this->times['open'] and $topic['topic_open_time']) {
                 if ($topic['state'] == 'closed') {
                     $updateTopicTable['state'] = 'open';
                 }
             }
         } else {
             if ($this->can_set_open_time and $topic['topic_open_time']) {
                 $updateTopicTable['topic_open_time'] = 0;
             }
         }
         if ($this->can_set_close_time and $this->times['close']) {
             $updateTopicTable['topic_close_time'] = intval($this->times['close']);
             //-----------------------------------------
             // Was a close time, but not now?
             //-----------------------------------------
             if (!$this->times['close'] and $topic['topic_close_time']) {
                 if ($topic['state'] == 'closed') {
                     $updateTopicTable['state'] = 'open';
                 }
             }
         } else {
             if ($this->can_set_close_time and $topic['topic_close_time']) {
                 $updateTopicTable['topic_close_time'] = 0;
             }
         }
         if ($this->edit_title) {
             if ($this->getForumID() != $topic['forum_id']) {
                 $updateTopicTable['forum_id'] = $this->getForumID();
             }
         }
     }
     //-----------------------------------------
     // Update poll
     //-----------------------------------------
     if ($this->can_add_poll) {
         if (is_array($this->poll_questions) and count($this->poll_questions)) {
             $poll_only = 0;
             if ($this->settings['ipb_poll_only'] and $this->request['poll_only'] == 1) {
                 $poll_only = 1;
             }
             $poll_view_voters = !$this->poll_data['votes'] ? $this->request['poll_view_voters'] : $this->poll_data['poll_view_voters'];
             if ($topic['poll_state']) {
                 $_pollData = array('votes' => intval($this->poll_total_votes), 'choices' => addslashes(serialize($this->poll_questions)), 'poll_question' => IPSText::stripAttachTag($this->request['poll_question']), 'poll_only' => $poll_only, 'poll_view_voters' => intval($poll_view_voters));
                 /* Data Hook Location */
                 IPSLib::doDataHooks($_pollData, 'editPostUpdatePoll');
                 $this->DB->update('polls', $_pollData, 'tid=' . $topic['tid']);
                 if ($this->poll_data['choices'] != serialize($this->poll_questions) or $this->poll_data['votes'] != intval($this->poll_total_votes)) {
                     $this->DB->insert('moderator_logs', array('forum_id' => $this->getForumData('id'), 'topic_id' => $topic['tid'], 'post_id' => $this->_originalPost['pid'], 'member_id' => $this->getAuthor('member_id'), 'member_name' => $this->getAuthor('members_display_name'), 'ip_address' => $this->ip_address, 'http_referer' => htmlspecialchars(my_getenv('HTTP_REFERER')), 'ctime' => IPS_UNIX_TIME_NOW, 'topic_title' => $topic['title'], 'action' => $this->lang->words['edited_poll'], 'query_string' => htmlspecialchars(my_getenv('QUERY_STRING'))));
                 }
             } else {
                 $_pollData = array('tid' => $topic['tid'], 'forum_id' => $this->getForumData('id'), 'start_date' => IPS_UNIX_TIME_NOW, 'choices' => addslashes(serialize($this->poll_questions)), 'starter_id' => $this->getAuthor('member_id'), 'votes' => 0, 'poll_question' => IPSText::stripAttachTag($this->request['poll_question']), 'poll_only' => $poll_only, 'poll_view_voters' => intval($poll_view_voters));
                 /* Data Hook Location */
                 IPSLib::doDataHooks($_pollData, 'editPostAddPoll');
                 $this->DB->insert('polls', $_pollData);
                 $this->DB->insert('moderator_logs', array('forum_id' => $this->getForumData('id'), 'topic_id' => $topic['tid'], 'post_id' => $this->_originalPost['pid'], 'member_id' => $this->getAuthor('member_id'), 'member_name' => $this->getAuthor('members_display_name'), 'ip_address' => $this->ip_address, 'http_referer' => htmlspecialchars(my_getenv('HTTP_REFERER')), 'ctime' => IPS_UNIX_TIME_NOW, 'topic_title' => $topic['title'], 'action' => sprintf($this->lang->words['added_poll'], $this->request['poll_question']), 'query_string' => htmlspecialchars(my_getenv('QUERY_STRING'))));
                 /* Update topics table later */
                 $updateTopicTable['poll_state'] = 1;
                 $updateTopicTable['last_vote'] = 0;
             }
         } else {
             /* Remove the poll */
             $this->DB->delete('polls', 'tid=' . $topic['tid']);
             $this->DB->delete('voters', 'tid=' . $topic['tid']);
             /* Update topics table later */
             $updateTopicTable['poll_state'] = 0;
             $updateTopicTable['last_vote'] = 0;
         }
     }
     //-----------------------------------------
     // Update topic title?
     //-----------------------------------------
     if ($this->edit_title == 1) {
         //-----------------------------------------
         // Update topic title
         //-----------------------------------------
         if ($this->_topicTitle != "") {
             if ($this->_topicTitle != $topic['title'] or !$topic['title_seo']) {
                 $updateTopicTable['title'] = $this->_topicTitle;
                 $updateTopicTable['title_seo'] = IPSText::makeSeoTitle($this->_topicTitle);
                 $_forumUpdate = array();
                 if ($topic['tid'] == $this->getForumData('last_id')) {
                     $_forumUpdate['last_title'] = $updateTopicTable['title'];
                     $_forumUpdate['seo_last_title'] = $updateTopicTable['title_seo'];
                 }
                 if ($topic['tid'] == $this->getForumData('newest_id')) {
                     $_forumUpdate['newest_title'] = $updateTopicTable['title'];
                 }
                 if (count($_forumUpdate)) {
                     $this->DB->update('forums', $_forumUpdate, 'id=' . $this->getForumData('id'));
                 }
                 if ($this->moderator['edit_topic'] == 1 or $this->getAuthor('g_is_supmod') == 1) {
                     $this->DB->insert('moderator_logs', array('forum_id' => $this->getForumData('id'), 'topic_id' => $topic['tid'], 'post_id' => $this->_originalPost['pid'], 'member_id' => $this->getAuthor('member_id'), 'member_name' => $this->getAuthor('members_display_name'), 'ip_address' => $this->ip_address, 'http_referer' => htmlspecialchars(my_getenv('HTTP_REFERER')), 'ctime' => IPS_UNIX_TIME_NOW, 'topic_title' => $topic['title'], 'action' => sprintf($this->lang->words['edited_topic_title'], $topic['title'], $this->_topicTitle), 'query_string' => htmlspecialchars(my_getenv('QUERY_STRING'))));
                 }
             }
         }
     }
     //-----------------------------------------
     // Reason for edit?
     //-----------------------------------------
     if ($this->_bypassPermChecks or isset($this->moderator['edit_post']) && $this->moderator['edit_post'] or $this->getAuthor('g_is_supmod')) {
         $post['post_edit_reason'] = trim($this->request['post_edit_reason']);
     }
     //-----------------------------------------
     // Update the database (ib_forum_post)
     //-----------------------------------------
     $post['append_edit'] = 1;
     if ($this->_bypassPermChecks or $this->getAuthor('g_append_edit')) {
         if ($this->request['add_edit'] != 1) {
             $post['append_edit'] = 0;
         }
     }
     /* HTML Status */
     $post['post_htmlstate'] = $this->getSettings('post_htmlstatus');
     /* Typecast */
     $this->DB->setDataType('post_edit_reason', 'string');
     /* Data Hook Location */
     IPSLib::doDataHooks($post, 'editPostData');
     $this->DB->update('posts', $post, 'pid=' . $this->_originalPost['pid']);
     /* Got a topic to update? */
     $updateTopicTable['post_data'] = $post;
     $updateTopicTable['forum_data'] = $this->getForumData();
     IPSLib::doDataHooks($updateTopicTable, 'editPostTopicData');
     unset($updateTopicTable['post_data'], $updateTopicTable['forum_data']);
     // Remove added data
     if (count($updateTopicTable)) {
         $this->DB->update('topics', $updateTopicTable, 'tid=' . $topic['tid']);
     }
     /* remove saved content */
     if ($this->memberData['member_id']) {
         $this->editor->removeAutoSavedContent(array('member_id' => $this->memberData['member_id'], 'autoSaveKey' => 'edit-' . intval($this->_originalPost['pid'])));
     }
     /* Add to cache */
     IPSContentCache::update($this->_originalPost['pid'], 'post', $this->formatPostForCache($post['post']));
     /* Upload Attachments */
     $this->uploadAttachments($this->post_key, $this->_originalPost['pid']);
     //-----------------------------------------
     // Make attachments "permanent"
     //-----------------------------------------
     $this->makeAttachmentsPermanent($this->post_key, $this->_originalPost['pid'], 'post', array('topic_id' => $topic['tid']));
     //-----------------------------------------
     // Make sure paperclip symbol is OK
     //-----------------------------------------
     $this->recountTopicAttachments($topic['tid']);
     //-----------------------------------------
     // Leave data for other apps
     //-----------------------------------------
     $this->setTopicData($topic);
     $this->setPostData(array_merge($this->_originalPost, $post));
     return TRUE;
 }
 /**
  * Edit a member [process]
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _memberDoEdit()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['member_id'] = intval($this->request['member_id']);
     //-----------------------------------------
     // Auth check...
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->checkSecurityKey($this->request['secure_key']);
     //-----------------------------------------
     // Load and config the std/rte editors
     //-----------------------------------------
     IPSText::getTextClass('editor')->from_acp = 1;
     //-----------------------------------------
     // Get member
     //-----------------------------------------
     $member = IPSMember::load($this->request['member_id'], 'all');
     //-----------------------------------------
     // Allowed to edit administrators?
     //-----------------------------------------
     if ($member['member_id'] != $this->memberData['member_id'] and $member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_edit_admin')) {
         $this->registry->output->global_message = $this->lang->words['m_editadmin'];
         $this->_memberView();
         return;
     }
     //-----------------------------------------
     // Allowed to change an admin's groups?
     //-----------------------------------------
     if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin1')) {
         $same = false;
         if ($this->request['member_group_id'] == $member['member_group_id']) {
             $omgroups = explode(',', IPSText::cleanPermString($member['mgroup_others']));
             $groups = $_POST['mgroup_others'] ? $_POST['mgroup_others'] : array();
             if (!count(array_diff($omgroups, $groups))) {
                 $same = true;
             }
         }
         if (!$same) {
             $this->registry->output->global_message = $this->lang->words['m_admindemote'];
             $this->_memberView();
             return;
         }
     }
     //-----------------------------------------
     // What about promoting to admin?
     //-----------------------------------------
     if (!$member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin2')) {
         $groups = $_POST['mgroup_others'] ? $_POST['mgroup_others'] : array();
         $groups[] = intval($this->request['member_group_id']);
         foreach ($groups as $group_id) {
             if ($this->caches['group_cache'][$group_id]['g_access_cp']) {
                 $this->registry->output->global_message = $this->lang->words['m_adminpromote'];
                 $this->_memberView();
                 return;
             }
         }
     }
     if ($this->request['identity_url']) {
         $account = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'members', 'where' => "identity_url='" . trim($this->request['identity_url']) . "' AND member_id<>" . $member['member_id']));
         if ($account['member_id']) {
             $this->registry->output->global_message = $this->lang->words['identity_url_inuse'];
             $this->_memberView();
             return;
         }
     }
     //-----------------------------------------
     // Convert sig
     //-----------------------------------------
     $signature = IPSText::getTextClass('editor')->processRawPost('signature');
     IPSText::getTextClass('bbcode')->parse_smilies = 0;
     IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['sig_allow_ibc'];
     IPSText::getTextClass('bbcode')->parse_html = $this->settings['sig_allow_html'];
     IPSText::getTextClass('bbcode')->parse_nl2br = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'signatures';
     $signature = IPSText::getTextClass('bbcode')->preDbParse($signature);
     $cacheSignature = IPSText::getTextClass('bbcode')->preDisplayParse($signature);
     //-----------------------------------------
     // And 'About Me'
     //-----------------------------------------
     $aboutme = IPSText::getTextClass('editor')->processRawPost('aboutme');
     IPSText::getTextClass('bbcode')->parse_smilies = $this->settings['aboutme_emoticons'];
     IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['aboutme_bbcode'];
     IPSText::getTextClass('bbcode')->parse_html = $this->settings['aboutme_html'];
     IPSText::getTextClass('bbcode')->parse_nl2br = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'aboutme';
     $aboutme = IPSText::getTextClass('bbcode')->preDbParse($aboutme);
     //-----------------------------------------
     // Ok? Load interface and child classes
     //-----------------------------------------
     $additionalCore = array();
     $additionalExtended = array();
     IPSLib::loadInterface('admin/member_form.php');
     foreach (ipsRegistry::$applications as $app_dir => $app_data) {
         if (!IPSLib::appIsInstalled($app_dir)) {
             continue;
         }
         if (file_exists(IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php')) {
             require_once IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php';
             $_class = 'admin_member_form__' . $app_dir;
             $_object = new $_class($this->registry);
             $remote = $_object->getForSave();
             $additionalCore = array_merge($remote['core'], $additionalCore);
             $additionalExtended = array_merge($remote['extendedProfile'], $additionalExtended);
         }
     }
     //-----------------------------------------
     // Fix custom title
     // @see	http://forums./index.php?app=tracker&showissue=17383
     //-----------------------------------------
     $memberTitle = $this->request['title'];
     $rankCache = ipsRegistry::cache()->getCache('ranks');
     if (is_array($rankCache) && count($rankCache)) {
         foreach ($rankCache as $k => $v) {
             if ($member['posts'] >= $v['POSTS']) {
                 /* If this is the title passed to us from the form, we didn't have a custom title */
                 if ($v['TITLE'] == $memberTitle) {
                     $memberTitle = '';
                 }
                 break;
             }
         }
     }
     $newMember = array('member_group_id' => intval($this->request['member_group_id']), 'title' => $memberTitle, 'time_offset' => floatval($this->request['time_offset']), 'language' => $this->request['language'], 'skin' => intval($this->request['skin']), 'hide_email' => intval($this->request['hide_email']), 'allow_admin_mails' => intval($this->request['allow_admin_mails']), 'view_sigs' => intval($this->request['view_sigs']), 'view_pop' => intval($this->request['view_pop']), 'email_pm' => intval($this->request['email_pm']), 'posts' => intval($this->request['posts']), 'bday_day' => intval($this->request['bday_day']), 'bday_month' => intval($this->request['bday_month']), 'bday_year' => intval($this->request['bday_year']), 'warn_level' => intval($this->request['warn_level']), 'members_disable_pm' => intval($this->request['members_disable_pm']), 'mgroup_others' => $_POST['mgroup_others'] ? ',' . implode(",", $_POST['mgroup_others']) . ',' : '', 'identity_url' => trim($this->request['identity_url']));
     //-----------------------------------------
     // Throw to the DB
     //-----------------------------------------
     IPSMember::save($this->request['member_id'], array('core' => array_merge($newMember, $additionalCore), 'extendedProfile' => array_merge(array('pp_gender' => $this->request['pp_gender'] == 'male' ? 'male' : ($this->request['pp_gender'] == 'female' ? 'female' : ''), 'pp_bio_content' => IPSText::mbsubstr(nl2br($this->request['pp_bio_content']), 0, 300), 'pp_about_me' => $aboutme, 'signature' => $signature, 'pp_reputation_points' => intval($this->request['pp_reputation_points']), 'pp_status' => $this->request['pp_status'], 'pp_setting_count_visitors' => intval($this->request['pp_setting_count_visitors']), 'pp_setting_count_comments' => intval($this->request['pp_setting_count_comments']), 'pp_setting_count_friends' => intval($this->request['pp_setting_count_friends']), 'pp_setting_notify_comments' => $this->request['pp_setting_notify_comments'], 'pp_setting_notify_friend' => $this->request['pp_setting_notify_friend'], 'pp_setting_moderate_comments' => intval($this->request['pp_setting_moderate_comments']), 'pp_setting_moderate_friends' => intval($this->request['pp_setting_moderate_friends'])), $additionalExtended)));
     if ($member['member_group_id'] != $newMember['member_group_id']) {
         IPSLib::runMemberSync('onGroupChange', $this->request['member_id'], $newMember['member_group_id']);
         //-----------------------------------------
         // Remove restrictions if member demoted
         // Commenting out as this may cause more problems than it's worth
         // e.g. if you had accidentally changed their group, you'd need to reconfigure all restrictions
         //-----------------------------------------
         /*if( !$this->caches['group_cache'][ $newMember['member_group_id'] ]['g_access_cp'] )
         		{
         			$this->DB->delete( 'admin_permission_rows', 'row_id=' . $member['member_id'] . " AND row_id_type='member'" );
         		}*/
     }
     //-----------------------------------------
     // Restriction permissions stuff
     //-----------------------------------------
     if (is_array($this->registry->getClass('class_permissions')->restrictions_row) and count($this->registry->getClass('class_permissions')->restrictions_row)) {
         $is_admin = 0;
         $groups = ipsRegistry::cache()->getCache('group_cache');
         if (is_array($this->request['mgroup_others']) and count($this->request['mgroup_others'])) {
             foreach ($this->request['mgroup_others'] as $omg) {
                 if ($groups[intval($omg)]['g_access_cp']) {
                     $is_admin = 1;
                     break;
                 }
             }
         }
         if ($groups[intval($this->request['member_group_id'])]['g_access_cp']) {
             $is_admin = 1;
         }
         if ($is_admin) {
             //-------------------------------------------------
             // Copy restrictions if they do not have any yet...
             //-------------------------------------------------
             $check = $this->DB->buildAndFetch(array('select' => 'row_updated', 'from' => 'admin_permission_rows', 'where' => "row_id_type='member' AND row_id=" . $this->request['member_id']));
             if (!$check['row_updated']) {
                 $this->DB->replace('admin_permission_rows', array('row_id' => $this->request['member_id'], 'row_id_type' => 'member', 'row_perm_cache' => serialize($this->registry->getClass('class_permissions')->restrictions_row), 'row_updated' => time()), array('row_id', 'row_id_type'));
             }
         }
     }
     //-----------------------------------------
     // Moved from validating group?
     //-----------------------------------------
     if ($member['member_group_id'] == $this->settings['auth_group']) {
         if ($this->request['member_group_id'] != $this->settings['auth_group']) {
             //-----------------------------------------
             // Yes...
             //-----------------------------------------
             $this->DB->delete('validating', "member_id=" . $this->request['member_id']);
         }
     }
     //-----------------------------------------
     // Custom profile field stuff
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
     $fields = new customProfileFields();
     $fields->initData('edit');
     $fields->parseToSave($_POST);
     //-----------------------------------------
     // Custom profile field stuff
     //-----------------------------------------
     if (count($fields->out_fields)) {
         //-----------------------------------------
         // Do we already have an entry in
         // the content table?
         //-----------------------------------------
         $test = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'pfields_content', 'where' => 'member_id=' . $this->request['member_id']));
         if ($test['member_id']) {
             //-----------------------------------------
             // We have it, so simply update
             //-----------------------------------------
             $this->DB->force_data_type = array();
             foreach ($fields->out_fields as $_field => $_data) {
                 $this->DB->force_data_type[$_field] = 'string';
             }
             $this->DB->update('pfields_content', $fields->out_fields, 'member_id=' . $this->request['member_id']);
         } else {
             $this->DB->force_data_type = array();
             foreach ($fields->out_fields as $_field => $_data) {
                 $this->DB->force_data_type[$_field] = 'string';
             }
             $fields->out_fields['member_id'] = $this->request['member_id'];
             $this->DB->insert('pfields_content', $fields->out_fields);
         }
     }
     /* Update cache */
     IPSContentCache::update($this->request['member_id'], 'sig', $cacheSignature);
     //-----------------------------------------
     // Redirect
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_editedlog'], $member['members_display_name']));
     $this->registry->output->global_message = $this->lang->words['m_edited'];
     $newMember['member_id'] = $this->request['member_id'];
     $newMember['members_display_name'] = $member['members_display_name'];
     $triggerGroups = $member['mgroup_others'] ? implode(',', array_merge(is_array($member['mgroup_others']) ? $member['mgroup_others'] : array(), array($member['member_group_id']))) : $member['member_group_id'];
     //$this->_memberView();
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=viewmember&trigger=' . $triggerGroups . '&member_id=' . $this->request['member_id']);
 }
示例#3
0
 /**
  * UserCP Save Form: Signature
  *
  * @return	array	Errors
  */
 public function saveSignature()
 {
     /* Load editor stuff */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite');
     $this->editor = new $classToLoad();
     $this->editor->setLegacyMode(false);
     $isHtml = intval($this->request['sig_htmlstatus']);
     //-----------------------------------------
     // Check to make sure that we can edit profiles..
     //-----------------------------------------
     $sig_restrictions = explode(':', $this->memberData['g_signature_limits']);
     if (!$this->memberData['g_edit_profile'] or $sig_restrictions[0] and !$this->memberData['g_sig_unit']) {
         $this->registry->getClass('output')->showError('members_profile_disabled', 1028, null, null, 403);
     }
     //-----------------------------------------
     // Post process the editor
     // Now we have safe HTML and bbcode
     //-----------------------------------------
     /* Set content in editor */
     $this->editor->setAllowBbcode(true);
     $this->editor->setAllowSmilies(true);
     $this->editor->setIsHtml($this->memberData['g_dohtml'] && $isHtml);
     $this->editor->setBbcodeSection('signatures');
     $this->editor->setContent($this->memberData['signature']);
     $signature = $this->editor->process($_POST['Post']);
     //-----------------------------------------
     // Parse post
     //-----------------------------------------
     /* Load parser */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
     $parser = new $classToLoad();
     $parser->testForParsingLimits($signature, array('quote', 'emoticons', 'urls'));
     if (is_array($parser->getErrors()) && count($parser->getErrors())) {
         $this->lang->loadLanguageFile(array('public_post'), 'forums');
         $_error = array_pop($parser->getErrors());
         $this->registry->getClass('output')->showError($_error, 10210);
     }
     //-----------------------------------------
     // Signature restrictions...
     //-----------------------------------------
     $sig_errors = array();
     //-----------------------------------------
     // Max number of images...
     //-----------------------------------------
     if (isset($sig_restrictions[1]) and $sig_restrictions[1] !== '') {
         if ($parser->getImageCount($signature) > $sig_restrictions[1]) {
             $sig_errors[] = sprintf($this->lang->words['sig_toomanyimages'], $sig_restrictions[1]);
         }
     }
     //-----------------------------------------
     // Max number of urls...
     //-----------------------------------------
     if (isset($sig_restrictions[4]) and $sig_restrictions[4] !== '') {
         if ($parser->getUrlCount($signature) > $sig_restrictions[4]) {
             $sig_errors[] = sprintf($this->lang->words['sig_toomanyurls'], $sig_restrictions[4]);
         } else {
             preg_match_all('#(^|\\s|>)((http|https|news|ftp)://\\w+[^\\s\\[\\]\\<]+)#is', $signature, $matches);
             if (count($matches[1]) > $sig_restrictions[4]) {
                 $sig_errors[] = sprintf($this->lang->words['sig_toomanyurls'], $sig_restrictions[4]);
             }
         }
     }
     $this->settings['signature_line_length'] = $this->settings['signature_line_length'] > 0 ? $this->settings['signature_line_length'] : 200;
     /* You can't wordwrap on HTML http://community.invisionpower.com/resources/bugs.html/_/ip-board/signature-url-bbcode-r41254 */
     //$signature	= wordwrap( $signature, $this->settings['signature_line_length'], '</p>', true );
     // http://community.invisionpower.com/tracker/issue-35105-signature-restriction-minor-bug
     $signature = preg_replace('#^\\s*(</p>)+#i', '', $signature);
     $signature = preg_replace('#(</p>)+?\\s*$#i', '', $signature);
     //-----------------------------------------
     // Max number of lines of text...
     //-----------------------------------------
     if (isset($sig_restrictions[5]) and $sig_restrictions[5] !== '') {
         $lineCount = substr_count($signature, "</p>") + substr_count($signature, "br>");
         if ($lineCount >= $sig_restrictions[5]) {
             $sig_errors[] = sprintf($this->lang->words['sig_toomanylines'], $sig_restrictions[5]);
         }
     }
     //-----------------------------------------
     // Now the crappy part..
     //-----------------------------------------
     if (isset($sig_restrictions[2]) and $sig_restrictions[2] !== '' and isset($sig_restrictions[3]) and $sig_restrictions[3] !== '') {
         preg_match_all('/\\<img([^>]+?)>/i', $signature, $allImages);
         if (count($allImages[1])) {
             foreach ($allImages[1] as $foundImage) {
                 preg_match('#src=[\'"]([^\'"]+?)[\'"]#i', $foundImage, $url);
                 $imageProperties = @getimagesize($url[1]);
                 if (is_array($imageProperties) and count($imageProperties)) {
                     if ($imageProperties[0] > $sig_restrictions[2] or $imageProperties[1] > $sig_restrictions[3]) {
                         $sig_errors[] = sprintf($this->lang->words['sig_imagetoobig'], $url[1], $sig_restrictions[2], $sig_restrictions[3]);
                     }
                 } else {
                     $sig_errors[] = $this->lang->words['sig_imagenotretrievable'];
                 }
             }
         }
     }
     if (count($sig_errors)) {
         $this->registry->getClass('output')->showError(implode('<br />', $sig_errors), 10211);
     }
     /* Save HTML status */
     $members_bitoptions = IPSBWOptions::thaw($this->memberData['members_bitoptions'], 'members', 'global');
     $members_bitoptions['bw_html_sig'] = $isHtml;
     //-----------------------------------------
     // Write it to the DB.
     //-----------------------------------------
     IPSMember::save($this->memberData['member_id'], array('members' => $members_bitoptions, 'extendedProfile' => array('signature' => $signature)));
     /* Update cache */
     IPSContentCache::update($this->memberData['member_id'], 'sig', $parser->display($signature));
     return TRUE;
 }
 /**
  * Parse a member for display
  *
  * @access	public
  * @param	mixed	Either array of member data, or member ID to self load
  * @param	array 	Array of flags to parse: 'signature', 'customFields', 'avatar', 'warn'
  * @return	array 	Parsed member data
  */
 public static function buildDisplayData($member, $_parseFlags = array())
 {
     $_NOW = IPSDebug::getMemoryDebugFlag();
     //-----------------------------------------
     // Figure out parse flags
     //-----------------------------------------
     $parseFlags = array('signature' => isset($_parseFlags['signature']) ? $_parseFlags['signature'] : 0, 'customFields' => isset($_parseFlags['customFields']) ? $_parseFlags['customFields'] : 0, 'avatar' => isset($_parseFlags['avatar']) ? $_parseFlags['avatar'] : 1, 'warn' => isset($_parseFlags['warn']) ? $_parseFlags['warn'] : 1, 'cfSkinGroup' => isset($_parseFlags['cfSkinGroup']) ? $_parseFlags['cfSkinGroup'] : '', 'cfGetGroupData' => isset($_parseFlags['cfGetGroupData']) ? $_parseFlags['cfGetGroupData'] : '', 'cfLocation' => isset($_parseFlags['cfLocation']) ? $_parseFlags['cfLocation'] : '', 'checkFormat' => isset($_parseFlags['checkFormat']) ? $_parseFlags['checkFormat'] : 0);
     if (isset($_parseFlags['__all__'])) {
         foreach ($parseFlags as $k => $v) {
             $parseFlags[$k] = 1;
         }
         $parseFlags['cfSkinGroup'] = '';
     }
     //-----------------------------------------
     // Load the member?
     //-----------------------------------------
     if (!is_array($member) and ($member == intval($member) and $member > 0)) {
         $member = self::load($member, 'all');
     }
     if (!$member['member_group_id']) {
         $member['member_group_id'] = ipsRegistry::$settings['guest_group'];
     }
     /* Unpack bitwise if required */
     if (!isset($member['bw_is_spammer'])) {
         $member = self::buildBitWiseOptions($member);
     }
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $rank_cache = ipsRegistry::cache()->getCache('ranks');
     $group_cache = ipsRegistry::cache()->getCache('group_cache');
     $group_name = IPSLib::makeNameFormatted($group_cache[$member['member_group_id']]['g_title'], $member['member_group_id']);
     $pips = 0;
     $topic_id = intval(isset(ipsRegistry::$request['t']) ? ipsRegistry::$request['t'] : 0);
     $forum_id = intval(isset(ipsRegistry::$request['f']) ? ipsRegistry::$request['f'] : 0);
     //-----------------------------------------
     // SEO Name
     //-----------------------------------------
     $member['members_seo_name'] = self::fetchSeoName($member);
     //-----------------------------------------
     // Avatar
     //-----------------------------------------
     if ($parseFlags['avatar']) {
         $member['avatar'] = self::buildAvatar($member);
     }
     $member['_group_formatted'] = $group_name;
     //-----------------------------------------
     // Ranks
     //-----------------------------------------
     if (is_array($rank_cache) and count($rank_cache)) {
         foreach ($rank_cache as $k => $v) {
             if ($member['posts'] >= $v['POSTS']) {
                 if (!isset($member['title']) || $member['title'] === '' || is_null($member['title'])) {
                     $member['title'] = $v['TITLE'];
                 }
                 $pips = $v['PIPS'];
                 break;
             }
         }
     }
     //-----------------------------------------
     // Group image
     //-----------------------------------------
     $member['member_rank_img'] = '';
     $member['member_rank_img_i'] = '';
     if ($group_cache[$member['member_group_id']]['g_icon']) {
         $_img = $group_cache[$member['member_group_id']]['g_icon'];
         if (substr($_img, 0, 4) != 'http') {
             $_img = ipsRegistry::$settings['_original_base_url'] . '/' . ltrim($_img, '/');
         }
         $member['member_rank_img_i'] = 'img';
         $member['member_rank_img'] = $_img;
     } else {
         if ($pips) {
             if (is_numeric($pips)) {
                 for ($i = 1; $i <= $pips; ++$i) {
                     $member['member_rank_img_i'] = 'pips';
                     $member['member_rank_img'] .= ipsRegistry::getClass('output')->getReplacement('pip_pip');
                 }
             } else {
                 $member['member_rank_img_i'] = 'img';
                 $member['member_rank_img'] = ipsRegistry::$settings['public_dir'] . 'style_extra/team_icons/' . $pips;
             }
         }
     }
     //-----------------------------------------
     // Spammer status
     //-----------------------------------------
     $member['spamStatus'] = NULL;
     $member['spamImage'] = NULL;
     $moderator = ipsRegistry::member()->getProperty('forumsModeratorData');
     if (isset($moderator[$forum_id]['bw_flag_spammers']) and $moderator[$forum_id]['bw_flag_spammers'] or ipsRegistry::member()->getProperty('g_is_supmod') == 1) {
         if (!ipsRegistry::$settings['warn_on'] or !strstr(',' . ipsRegistry::$settings['warn_protected'] . ',', ',' . $member['member_group_id'] . ',')) {
             if ($member['bw_is_spammer']) {
                 $member['spamStatus'] = TRUE;
             } else {
                 $member['spamStatus'] = FALSE;
             }
         }
     }
     //-----------------------------------------
     // Warny porny?
     //-----------------------------------------
     if ($parseFlags['warn'] and $member['member_id']) {
         $member['warn_percent'] = NULL;
         $member['can_edit_warn'] = false;
         $member['warn_img'] = NULL;
         if (ipsRegistry::$settings['warn_on'] and !strstr(',' . ipsRegistry::$settings['warn_protected'] . ',', ',' . $member['member_group_id'] . ',')) {
             /* Warnings */
             if (isset($moderator[$forum_id]['allow_warn']) and $moderator[$forum_id]['allow_warn'] or ipsRegistry::member()->getProperty('g_is_supmod') == 1 or ipsRegistry::$settings['warn_show_own'] and ipsRegistry::member()->getProperty('member_id') == $member['member_id']) {
                 // Work out which image to show.
                 if ($member['warn_level'] <= ipsRegistry::$settings['warn_min']) {
                     $member['warn_img'] = '{parse replacement="warn_0"}';
                     $member['warn_percent'] = 0;
                 } else {
                     if ($member['warn_level'] >= ipsRegistry::$settings['warn_max']) {
                         $member['warn_img'] = '{parse replacement="warn_5"}';
                         $member['warn_percent'] = 100;
                     } else {
                         $member['warn_percent'] = $member['warn_level'] ? sprintf("%.0f", $member['warn_level'] / ipsRegistry::$settings['warn_max'] * 100) : 0;
                         if ($member['warn_percent'] > 100) {
                             $member['warn_percent'] = 100;
                         }
                         if ($member['warn_percent'] >= 81) {
                             $member['warn_img'] = '{parse replacement="warn_5"}';
                         } else {
                             if ($member['warn_percent'] >= 61) {
                                 $member['warn_img'] = '{parse replacement="warn_4"}';
                             } else {
                                 if ($member['warn_percent'] >= 41) {
                                     $member['warn_img'] = '{parse replacement="warn_3"}';
                                 } else {
                                     if ($member['warn_percent'] >= 21) {
                                         $member['warn_img'] = '{parse replacement="warn_2"}';
                                     } else {
                                         if ($member['warn_percent'] >= 1) {
                                             $member['warn_img'] = '{parse replacement="warn_1"}';
                                         } else {
                                             $member['warn_img'] = '{parse replacement="warn_0"}';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($member['warn_percent'] < 1) {
                     $member['warn_percent'] = 0;
                 }
                 /* Bug 14770 - Change so you can't warn yourself */
                 if ((isset($moderator[$forum_id]['allow_warn']) and $moderator[$forum_id]['allow_warn'] or ipsRegistry::member()->getProperty('g_is_supmod') == 1) and $member['member_id'] != ipsRegistry::member()->getProperty('member_id')) {
                     $member['can_edit_warn'] = true;
                 }
             }
         }
     }
     //-----------------------------------------
     // Profile fields stuff
     //-----------------------------------------
     $member['custom_fields'] = "";
     if ($parseFlags['customFields'] == 1 and $member['member_id']) {
         if (isset(self::$_parsedCustomFields[$member['member_id']])) {
             $member['custom_fields'] = self::$_parsedCustomFields[$member['member_id']];
             if ($parseFlags['cfGetGroupData'] and isset(self::$_parsedCustomGroups[$member['member_id']]) and is_array(self::$_parsedCustomGroups[$member['member_id']])) {
                 $member['custom_field_groups'] = self::$_parsedCustomGroups[$member['member_id']];
             }
         } else {
             if (!is_object(self::$custom_fields_class)) {
                 require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
                 self::$custom_fields_class = new customProfileFields();
             }
             if (self::$custom_fields_class) {
                 self::$custom_fields_class->member_data = $member;
                 self::$custom_fields_class->skinGroup = $parseFlags['cfSkinGroup'];
                 self::$custom_fields_class->initData();
                 self::$custom_fields_class->parseToView($parseFlags['checkFormat'], $parseFlags['cfLocation']);
                 $member['custom_fields'] = self::$custom_fields_class->out_fields;
                 self::$_parsedCustomFields[$member['member_id']] = $member['custom_fields'];
                 if ($parseFlags['cfGetGroupData']) {
                     $member['custom_field_groups'] = self::$custom_fields_class->fetchGroupTitles();
                     self::$_parsedCustomGroups[$member['member_id']] = $member['custom_field_groups'];
                 }
             }
         }
     }
     //-----------------------------------------
     // Profile photo
     //-----------------------------------------
     $member = self::buildProfilePhoto($member);
     //-----------------------------------------
     // Personal statement 'bbcode'
     //-----------------------------------------
     if (stripos($member['pp_bio_content'], '[b]') !== false) {
         if (stripos($member['pp_bio_content'], '[/b]') > stripos($member['pp_bio_content'], '[b]')) {
             $member['pp_bio_content'] = str_ireplace('[b]', '<strong>', $member['pp_bio_content']);
             $member['pp_bio_content'] = str_ireplace('[/b]', '</strong>', $member['pp_bio_content']);
         }
     }
     if (stripos($member['pp_bio_content'], '[i]') !== false) {
         if (stripos($member['pp_bio_content'], '[/i]') > stripos($member['pp_bio_content'], '[i]')) {
             $member['pp_bio_content'] = str_ireplace('[i]', '<em>', $member['pp_bio_content']);
             $member['pp_bio_content'] = str_ireplace('[/i]', '</em>', $member['pp_bio_content']);
         }
     }
     if (stripos($member['pp_bio_content'], '[u]') !== false) {
         if (stripos($member['pp_bio_content'], '[/u]') > stripos($member['pp_bio_content'], '[u]')) {
             $member['pp_bio_content'] = str_ireplace('[u]', '<span class="underscore">', $member['pp_bio_content']);
             $member['pp_bio_content'] = str_ireplace('[/u]', '</span>', $member['pp_bio_content']);
         }
     }
     //-----------------------------------------
     // Signature bbcode
     //-----------------------------------------
     if (isset($member['signature']) and $member['signature'] and $parseFlags['signature']) {
         if (isset(self::$_parsedSignatures[$member['member_id']])) {
             $member['signature'] = self::$_parsedSignatures[$member['member_id']];
         } else {
             if ($member['cache_content']) {
                 $member['signature'] = '<!--cached-' . gmdate('r', $member['cache_updated']) . '-->' . $member['cache_content'];
             } else {
                 IPSText::getTextClass('bbcode')->parse_bbcode = ipsRegistry::$settings['sig_allow_ibc'];
                 IPSText::getTextClass('bbcode')->parse_smilies = 1;
                 IPSText::getTextClass('bbcode')->parse_html = ipsRegistry::$settings['sig_allow_html'];
                 IPSText::getTextClass('bbcode')->parse_nl2br = 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']);
                 IPSContentCache::update($member['member_id'], 'sig', $member['signature']);
             }
             self::$_parsedSignatures[$member['member_id']] = $member['signature'];
         }
     }
     //-----------------------------------------
     // If current session, reset last_activity
     //-----------------------------------------
     if (!empty($member['running_time'])) {
         $member['last_activity'] = $member['running_time'] > $member['last_activity'] ? $member['running_time'] : $member['last_activity'];
     }
     //-----------------------------------------
     // Online?
     //-----------------------------------------
     $time_limit = time() - ipsRegistry::$settings['au_cutoff'] * 60;
     $member['_online'] = 0;
     if (!ipsRegistry::$settings['disable_anonymous'] and isset($member['login_anonymous'])) {
         list($be_anon, $loggedin) = explode('&', $member['login_anonymous']);
     } else {
         $be_anon = 0;
         $loggedin = $member['last_activity'] > $time_limit ? 1 : 0;
     }
     $bypass_anon = 0;
     $our_mgroups = array();
     if (ipsRegistry::member()->getProperty('mgroup_others')) {
         $our_mgroups = explode(",", IPSText::cleanPermString(ipsRegistry::member()->getProperty('mgroup_others')));
     }
     $our_mgroups[] = ipsRegistry::member()->getProperty('member_group_id');
     if (ipsRegistry::member()->getProperty('g_access_cp') and !ipsRegistry::$settings['disable_admin_anon']) {
         $bypass_anon = 1;
     }
     if (($member['last_visit'] > $time_limit or $member['last_activity'] > $time_limit) and ($be_anon != 1 or $bypass_anon == 1) and $loggedin == 1) {
         $member['_online'] = 1;
     }
     //-----------------------------------------
     // Last Active
     //-----------------------------------------
     $member['_last_active'] = ipsRegistry::getClass('class_localization')->getDate($member['last_activity'], 'SHORT');
     if ($be_anon == 1) {
         // Member last logged in anonymous
         if (!ipsRegistry::member()->getProperty('g_access_cp') or ipsRegistry::$settings['disable_admin_anon']) {
             $member['_last_active'] = ipsRegistry::getClass('class_localization')->words['private'];
         }
     }
     //-----------------------------------------
     // Rating
     //-----------------------------------------
     $member['_pp_rating_real'] = intval($member['pp_rating_real']);
     //-----------------------------------------
     // Long display names
     //-----------------------------------------
     $member['members_display_name_short'] = IPSText::truncate($member['members_display_name'], 16);
     //-----------------------------------------
     // Reputation
     //-----------------------------------------
     if (!ipsRegistry::isClassLoaded('repCache')) {
         require_once IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php';
         ipsRegistry::setClass('repCache', new classReputationCache());
     }
     $member['pp_reputation_points'] = $member['pp_reputation_points'] ? $member['pp_reputation_points'] : 0;
     $member['author_reputation'] = ipsRegistry::getClass('repCache')->getReputation($member['pp_reputation_points']);
     //-----------------------------------------
     // Other stuff not worthy of individual comments
     //-----------------------------------------
     $member['members_profile_views'] = isset($member['members_profile_views']) ? $member['members_profile_views'] : 0;
     $member['_pp_profile_views'] = ipsRegistry::getClass('class_localization')->formatNumber($member['members_profile_views']);
     IPSDebug::setMemoryDebugFlag("IPSMember::buildDisplayData: " . $member['member_id'] . " - Completed", $_NOW);
     return $member;
 }
 /**
  * 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);
 }
示例#6
0
 /**
  * Edit a member [process]
  *
  * @return	@e void
  */
 protected function _memberDoEdit()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['member_id'] = intval($this->request['member_id']);
     //-----------------------------------------
     // Send to form if this isn't a POST request
     //-----------------------------------------
     if ($this->request['request_method'] != 'post') {
         $this->_memberView();
         return;
     }
     //-----------------------------------------
     // Auth check...
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->checkSecurityKey($this->request['secure_key']);
     //-----------------------------------------
     // Load and config the std/rte editors
     //-----------------------------------------
     IPSText::getTextClass('editor')->from_acp = 1;
     //-----------------------------------------
     // Get member
     //-----------------------------------------
     $member = IPSMember::load($this->request['member_id'], 'all');
     //-----------------------------------------
     // Allowed to edit administrators?
     //-----------------------------------------
     if ($member['member_id'] != $this->memberData['member_id'] and $member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_edit_admin')) {
         $this->registry->output->global_message = $this->lang->words['m_editadmin'];
         $this->_memberView();
         return;
     }
     //-----------------------------------------
     // Allowed to change an admin's groups?
     //-----------------------------------------
     if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin1')) {
         $same = false;
         if ($this->request['member_group_id'] == $member['member_group_id']) {
             $member['mgroup_others'] = IPSText::cleanPermString($member['mgroup_others']);
             $omgroups = $member['mgroup_others'] ? explode(',', $member['mgroup_others']) : array();
             $groups = $this->request['mgroup_others'] ? $this->request['mgroup_others'] : array();
             if (!count(array_diff($omgroups, $groups)) and !count(array_diff($groups, $omgroups))) {
                 $same = true;
             }
         }
         if (!$same) {
             $this->registry->output->global_message = $this->lang->words['m_admindemote'];
             $this->_memberView();
             return;
         }
     }
     //-----------------------------------------
     // What about promoting to admin?
     //-----------------------------------------
     if (!$member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin2')) {
         $groups = $_POST['mgroup_others'] ? $_POST['mgroup_others'] : array();
         $groups[] = intval($this->request['member_group_id']);
         foreach ($groups as $group_id) {
             if ($this->caches['group_cache'][$group_id]['g_access_cp']) {
                 $this->registry->output->global_message = $this->lang->words['m_adminpromote'];
                 $this->_memberView();
                 return;
             }
         }
     }
     //-----------------------------------------
     // What about moving member in general?
     //-----------------------------------------
     if ($this->request['member_group_id'] != $member['member_group_id'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move')) {
         $this->registry->output->global_message = $this->lang->words['m_movemembers'];
         $this->_memberView();
         return;
     }
     //-----------------------------------------
     // Restricted?
     //-----------------------------------------
     $restricted = (is_array($this->registry->getClass('class_permissions')->restrictions_row) and count($this->registry->getClass('class_permissions')->restrictions_row)) ? true : false;
     /* Load editor stuff */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite');
     $_editor = new $classToLoad();
     /* Load parser */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
     $parser = new $classToLoad();
     /* Get signature */
     $_editor->setAllowBbcode(true);
     $_editor->setAllowSmilies(false);
     $_editor->setIsHtml($this->request['bw_html_sig'] && $member['g_dohtml']);
     $_editor->setAllowHtml($member['g_dohtml']);
     $_editor->setBbcodeSection('signatures');
     $signature = $_editor->process($_POST['signature']);
     $cacheSignature = $parser->display($signature);
     /* About me editor */
     $_editor->setAllowBbcode(true);
     $_editor->setAllowSmilies(true);
     $_editor->setAllowHtml($member['g_dohtml']);
     $_editor->setBbcodeSection('aboutme');
     $aboutme = $_editor->process($_POST['aboutme']);
     //-----------------------------------------
     // Ok? Load interface and child classes
     //-----------------------------------------
     $additionalCore = array();
     $additionalExtended = array();
     $additionalMCache = array();
     IPSLib::loadInterface('admin/member_form.php');
     foreach (IPSLib::getEnabledApplications() as $app_dir => $app_data) {
         if (is_file(IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php')) {
             $_class = IPSLib::loadLibrary(IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php', 'admin_member_form__' . $app_dir, $app_dir);
             $_object = new $_class($this->registry);
             $remote = $_object->getForSave();
             $additionalCore = is_array($remote['core']) ? array_merge($remote['core'], $additionalCore) : $additionalCore;
             $additionalExtended = is_array($remote['extendedProfile']) ? array_merge($remote['extendedProfile'], $additionalExtended) : $additionalExtended;
             $additionalMCache = is_array($remote['member_cache']) ? array_merge($remote['member_cache'], $additionalMCache) : $additionalMCache;
         }
     }
     //-----------------------------------------
     // Fix custom title
     // @see	http://forums.invisionpower.com/index.php?app=tracker&showissue=17383
     //-----------------------------------------
     $memberTitle = $this->request['title'];
     $rankCache = ipsRegistry::cache()->getCache('ranks');
     if (is_array($rankCache) && count($rankCache)) {
         foreach ($rankCache as $k => $v) {
             if ($member['posts'] >= $v['POSTS']) {
                 /* If this is the title passed to us from the form, we didn't have a custom title */
                 if ($v['TITLE'] == $memberTitle) {
                     $memberTitle = '';
                 }
                 break;
             }
         }
     }
     //-----------------------------------------
     // Start array
     //-----------------------------------------
     $newMember = array('member_group_id' => intval($this->request['member_group_id']), 'title' => $memberTitle, 'time_offset' => floatval($this->request['time_offset']), 'members_auto_dst' => intval($this->request['dstCheck']), 'dst_in_use' => intval($this->request['dstOption']), 'language' => $this->request['language'], 'skin' => intval($this->request['skin']), 'allow_admin_mails' => intval($this->request['allow_admin_mails']), 'view_sigs' => intval($this->request['view_sigs']), 'posts' => intval($this->request['posts']), 'bday_day' => intval($this->request['bday_day']), 'bday_month' => intval($this->request['bday_month']), 'bday_year' => intval($this->request['bday_year']), 'warn_level' => intval($this->request['warn_level']), 'members_disable_pm' => intval($this->request['members_disable_pm']), 'mgroup_others' => $this->request['mgroup_others'] ? ',' . implode(",", $this->request['mgroup_others']) . ',' : '', 'members_bitoptions' => IPSBWOPtions::freeze($this->request, 'members', 'global'), 'member_uploader' => $this->request['member_uploader']);
     //-----------------------------------------
     // Notifications library
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications');
     $notifyLibrary = new $classToLoad($this->registry);
     $notifyLibrary->setMember($member);
     //-----------------------------------------
     // Show the form
     //-----------------------------------------
     $_basicOptions = array(array('email', $this->lang->words['notopt__email']), array('inline', $this->lang->words['notopt__inline']), array('mobile', $this->lang->words['notopt__mobile']));
     $_configOptions = $notifyLibrary->getNotificationData();
     $_notifyConfig = $notifyLibrary->getMemberNotificationConfig($newMember);
     $_defaultConfig = $notifyLibrary->getDefaultNotificationConfig();
     $_saveConfig = array();
     foreach ($_configOptions as $option) {
         $_saveConfig[$option['key']] = array();
         $_saveConfig[$option['key']]['selected'] = array();
         //-----------------------------------------
         // Loop through and mark what we selected.
         // Do not allow changing of stuff from disable_override
         //	and disabled, however
         //-----------------------------------------
         if (is_array($this->request['config_' . $option['key']]) and count($this->request['config_' . $option['key']])) {
             foreach ($this->request['config_' . $option['key']] as $_selected) {
                 if (!is_array($_defaultConfig[$option['key']]['disabled']) or !in_array($_selected, $_defaultConfig[$option['key']]['disabled'])) {
                     $_saveConfig[$option['key']]['selected'][] = $_selected;
                 }
             }
         }
         if ($_defaultConfig[$option['key']]['disable_override']) {
             $_saveConfig[$option['key']]['selected'] = $_defaultConfig[$option['key']]['selected'];
         }
     }
     //-----------------------------------------
     // Save
     //-----------------------------------------
     IPSMember::packMemberCache($member['member_id'], array_merge($additionalMCache, array('notifications' => $_saveConfig, 'show_notification_popup' => intval($this->request['show_notification_popup']))), $member['members_cache']);
     //-----------------------------------------
     // Topic preferences
     //-----------------------------------------
     $_trackChoice = '';
     if ($this->request['auto_track']) {
         if (in_array($this->request['auto_track_method'], array('none', 'immediate', 'offline', 'daily', 'weekly'))) {
             $_trackChoice = $this->request['auto_track_method'];
         }
     }
     $newMember['auto_track'] = $_trackChoice;
     //-----------------------------------------
     // Custom profile field stuff
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields');
     $fields = new $classToLoad();
     $fields->initData('edit');
     $fields->parseToSave($_POST);
     /* Check the website url field */
     $website_field = $fields->getFieldIDByKey('website');
     if ($website_field && $fields->out_fields['field_' . $website_field]) {
         if (stristr($fields->out_fields['field_' . $website_field], 'http://') === FALSE && stristr($fields->out_fields['field_' . $website_field], 'https://') === FALSE) {
             $fields->out_fields['field_' . $website_field] = 'http://' . $fields->out_fields['field_' . $website_field];
         }
     }
     //-----------------------------------------
     // Throw to the DB
     //-----------------------------------------
     IPSMember::save($this->request['member_id'], array('core' => array_merge($newMember, $additionalCore), 'extendedProfile' => array_merge(array('pp_about_me' => $aboutme, 'signature' => $signature, 'pp_reputation_points' => intval($this->request['pp_reputation_points']), 'pp_setting_count_visitors' => intval($this->request['pp_setting_count_visitors']), 'pp_setting_count_comments' => intval($this->request['pp_setting_count_comments']), 'pp_setting_count_friends' => intval($this->request['pp_setting_count_friends']), 'pp_setting_moderate_comments' => intval($this->request['pp_setting_moderate_comments']), 'pp_setting_moderate_friends' => intval($this->request['pp_setting_moderate_friends']), 'pp_customization' => $this->request['removeCustomization'] ? serialize(array()) : $member['pp_customization']), $additionalExtended), 'customFields' => count($fields->out_fields) ? $fields->out_fields : array()));
     if ($member['member_group_id'] != $newMember['member_group_id']) {
         IPSLib::runMemberSync('onGroupChange', $this->request['member_id'], $newMember['member_group_id'], $member['member_group_id']);
         //-----------------------------------------
         // Remove restrictions if member demoted
         // Commenting out as this may cause more problems than it's worth
         // e.g. if you had accidentally changed their group, you'd need to reconfigure all restrictions
         //-----------------------------------------
         /*if( !$this->caches['group_cache'][ $newMember['member_group_id'] ]['g_access_cp'] )
         		{
         			$this->DB->delete( 'admin_permission_rows', 'row_id=' . $member['member_id'] . " AND row_id_type='member'" );
         		}*/
         //-----------------------------------------
         // Restriction permissions stuff
         //-----------------------------------------
         $is_admin = 0;
         $groups = ipsRegistry::cache()->getCache('group_cache');
         if (is_array($this->request['mgroup_others']) and count($this->request['mgroup_others'])) {
             foreach ($this->request['mgroup_others'] as $omg) {
                 if ($groups[intval($omg)]['g_access_cp']) {
                     $is_admin = 1;
                     break;
                 }
             }
         }
         if ($groups[intval($this->request['member_group_id'])]['g_access_cp']) {
             $is_admin = 1;
         }
         if ($is_admin && $restricted) {
             //-------------------------------------------------
             // Copy restrictions if they do not have any yet...
             //-------------------------------------------------
             $check = $this->DB->buildAndFetch(array('select' => 'row_updated', 'from' => 'admin_permission_rows', 'where' => "row_id_type='member' AND row_id=" . $this->request['member_id']));
             if (!$check['row_updated']) {
                 $this->DB->replace('admin_permission_rows', array('row_id' => $this->request['member_id'], 'row_id_type' => 'member', 'row_perm_cache' => serialize($this->registry->getClass('class_permissions')->restrictions_row), 'row_updated' => time()), array('row_id', 'row_id_type'));
             }
         }
     }
     //-----------------------------------------
     // Moved from validating group?
     //-----------------------------------------
     if ($member['member_group_id'] == $this->settings['auth_group']) {
         if ($this->request['member_group_id'] != $this->settings['auth_group']) {
             //-----------------------------------------
             // Yes...
             //-----------------------------------------
             $this->DB->delete('validating', "member_id=" . $this->request['member_id']);
         }
     }
     /* Update cache */
     IPSContentCache::update($this->request['member_id'], 'sig', $cacheSignature);
     /* Rebuild birthday cache */
     $this->cache->rebuildCache('birthdays', 'calendar');
     //-----------------------------------------
     // Redirect
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_editedlog'], $member['members_display_name']));
     $this->registry->output->global_message = $this->lang->words['m_edited'];
     if ($is_admin) {
         if (!$restricted) {
             $member = IPSMember::load($member['member_id']);
             $this->_showAdminForm($member, array());
             $this->_memberView();
         } else {
             $this->registry->output->global_message = $this->lang->words['m_edited_restricted'];
             $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=viewmember&member_id=' . $this->request['member_id']);
         }
     } else {
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=viewmember&member_id=' . $this->request['member_id']);
     }
 }
 /**
  * Flag an account as spammer
  *
  * @param	int|array	$member				Member Data
  * @param	array		$marker				The person marking this person a spammer
  * @param	bool		$resetLastMember	If FALSE skips resetting the last registered member
  * @return	void
  */
 public static function flagMemberAsSpammer($member, $marker = NULL, $resetLastMember = TRUE)
 {
     //-----------------------------------------
     // Init
     //-----------------------------------------
     /* Load Member */
     if (!is_array($member)) {
         $member = self::load($member);
     }
     /* Load moderator library (we'll need this to unapprove posts and log) */
     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums');
     $modLibrary = new $classToLoad(ipsRegistry::instance());
     //-----------------------------------------
     // Do it
     //-----------------------------------------
     $toSave = array();
     $toSave['core']['bw_is_spammer'] = TRUE;
     /* Shut off twitter/FB status importing */
     $bwOptions = IPSBWOptions::thaw($member['tc_bwoptions'], 'twitter');
     $bwOptions['tc_si_status'] = 0;
     $twitter = IPSBWOptions::freeze($bwOptions, 'twitter');
     $bwOptions = IPSBWOptions::thaw($member['fb_bwoptions'], 'facebook');
     $bwOptions['fbc_si_status'] = 0;
     $facebook = IPSBWOptions::freeze($bwOptions, 'facebook');
     $toSave['extendedProfile']['tc_bwoptions'] = $twitter;
     $toSave['extendedProfile']['fb_bwoptions'] = $facebook;
     /* Do any disabling, unapproving, banning - no breaks here since if we ban, we also want to unapprove posts, etc. */
     /* Note that there are DELIBERATELY no breaks in this switch since the options are cascading (if you ban, you also want to unapprove content) */
     switch (ipsRegistry::$settings['spm_option']) {
         /* Empty profile and ban account */
         case 'ban':
             // ban
             $toSave['core']['member_banned'] = TRUE;
             // wipe data
             $toSave['core']['title'] = '';
             $toSave['extendedProfile']['signature'] = '';
             $toSave['extendedProfile']['pp_about_me'] = '';
             // wipe photo
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/member/photo.php', 'classes_member_photo');
             $photos = new $classToLoad(ipsRegistry::instance());
             $photos->remove($member['member_id']);
             // wipe custom fields
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields');
             $fields = new $classToLoad();
             $fields->member_data = $member;
             $fields->initData('edit');
             $fields->parseToSave(array());
             if (count($fields->out_fields)) {
                 $toSave['customFields'] = $fields->out_fields;
             }
             // wipe signature
             IPSContentCache::update($member['member_id'], 'sig', '');
             /* Unapprove posts */
         /* Unapprove posts */
         case 'unapprove':
             $modLibrary->deleteMemberContent($member['member_id'], 'all', intval(ipsRegistry::$settings['spm_post_days']) * 24);
             /* Disable Post/PM permission */
         /* Disable Post/PM permission */
         case 'disable':
             $toSave['core']['restrict_post'] = 1;
             $toSave['core']['members_disable_pm'] = 2;
     }
     self::save($member['member_id'], $toSave);
     //-----------------------------------------
     // Run memberSync
     //-----------------------------------------
     IPSLib::runMemberSync('onSetAsSpammer', array_merge($member, $toSave));
     //-----------------------------------------
     // Let the admin know if necessary
     //-----------------------------------------
     if ($marker !== NULL and ipsRegistry::$settings['spm_notify'] and ipsRegistry::$settings['email_in'] != $marker['email']) {
         ipsRegistry::getClass('class_localization')->loadLanguageFile(array('public_mod'), 'forums');
         ipsRegistry::getClass('class_localization')->loadLanguageFile(array('admin_member'), 'members');
         IPSText::getTextClass('email')->getTemplate('possibleSpammer');
         IPSText::getTextClass('email')->buildMessage(array('DATE' => ipsRegistry::getClass('class_localization')->getDate($member['joined'], 'LONG', 1), 'MEMBER_NAME' => $member['members_display_name'], 'IP' => $member['ip_address'], 'EMAIL' => $member['email'], 'LINK' => ipsRegistry::getClass('output')->buildSEOUrl("showuser=" . $member['member_id'], 'public', $member['members_seo_name'], 'showuser')));
         IPSText::getTextClass('email')->subject = sprintf(ipsRegistry::getClass('class_localization')->words['new_registration_email_spammer'], ipsRegistry::$settings['board_name']);
         IPSText::getTextClass('email')->to = ipsRegistry::$settings['email_in'];
         IPSText::getTextClass('email')->sendMail();
     }
     /* Reset last member? */
     if ($resetLastMember) {
         self::resetLastRegisteredMember();
     }
     //-----------------------------------------
     // Let IPS know
     //-----------------------------------------
     if (ipsRegistry::$settings['spam_service_send_to_ips']) {
         self::querySpamService($member['email'], $member['ip_address'], 'markspam');
     }
     //-----------------------------------------
     // Log
     //-----------------------------------------
     ipsRegistry::getClass('class_localization')->loadLanguageFile(array('public_modcp'), 'core');
     $modLibrary->addModerateLog(0, 0, 0, 0, ipsRegistry::getClass('class_localization')->words['flag_spam_done'] . ': ' . $member['member_id'] . ' - ' . $member['email']);
 }
示例#8
0
 /**
  * Feturn HTML block
  *
  * @param	array		Member information
  * @return	string		HTML block
  */
 public function return_html_block($member = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $content = '';
     $last_x = 5;
     $forumIdsOk = array(0 => 0);
     $date_cut = '';
     //-----------------------------------------
     // Got a member?
     //-----------------------------------------
     if (!is_array($member) or !count($member)) {
         return $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_posts_to_show');
     }
     //-----------------------------------------
     // Some words
     //-----------------------------------------
     $this->registry->class_localization->loadLanguageFile(array('public_topic'), 'forums');
     //-----------------------------------------
     // Can view other member's topics?
     //-----------------------------------------
     if (!$this->memberData['g_other_topics'] and $this->memberData['member_id'] != $member['member_id']) {
         return $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_posts_to_show');
     }
     /* Get list of good forum IDs */
     $forumIdsOk = $this->registry->class_forums->fetchSearchableForumIds();
     //-----------------------------------------
     // Get last X posts
     //-----------------------------------------
     if (is_array($forumIdsOk) and count($forumIdsOk)) {
         /* Init vars */
         $pids = array();
         $parseAttachments = false;
         /* Set up joins */
         $_post_joins = array(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id', 'type' => 'left'), array('select' => 'm.member_group_id, m.mgroup_others', 'from' => array('members' => 'm'), 'where' => 'm.member_id=p.author_id', 'type' => 'left'));
         /* Cache? */
         if (IPSContentCache::isEnabled()) {
             if (IPSContentCache::fetchSettingValue('post')) {
                 $_post_joins[] = IPSContentCache::join('post', 'p.pid');
             }
         }
         if ($this->settings['search_ucontent_days']) {
             $_date_cut = ($member['last_post'] ? $member['last_post'] : time()) - 86400 * intval($this->settings['search_ucontent_days']);
             $date_cut = ' AND p.post_date > ' . $_date_cut;
         }
         $_queued = $this->registry->class_forums->fetchPostHiddenQuery(array('visible'), 'p.');
         $_approved = $this->registry->getClass('class_forums')->fetchTopicHiddenQuery(array('visible'), 't.');
         /* Let's just run this if the member has posted within the cutoff period */
         if ($member['last_post'] > $_date_cut) {
             $this->DB->build(array('select' => 'p.*', 'from' => array('posts' => 'p'), 'where' => $_queued . " AND " . $_approved . " AND p.author_id={$member['member_id']} AND p.new_topic=0 AND t.forum_id IN (" . implode(",", $forumIdsOk) . ") " . $date_cut, 'order' => 'p.pid DESC', 'limit' => array(0, $last_x), 'add_join' => $_post_joins));
             $o = $this->DB->execute();
             while ($row = $this->DB->fetch($o)) {
                 $pids[$row['pid']] = $row['pid'];
                 if ($row['topic_hasattach']) {
                     $parseAttachments = true;
                 }
                 if (!$row['cache_content']) {
                     IPSText::getTextClass('bbcode')->parse_smilies = $row['use_emo'];
                     IPSText::getTextClass('bbcode')->parse_html = ($row['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 = 1;
                     IPSText::getTextClass('bbcode')->parsing_section = 'topics';
                     IPSText::getTextClass('bbcode')->parsing_mgroup = $row['member_group_id'];
                     IPSText::getTextClass('bbcode')->parsing_mgroup_others = $row['mgroup_others'];
                     $row['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($row['post']);
                     IPSContentCache::update($row['pid'], 'post', $row['post']);
                 } else {
                     $row['post'] = $row['cache_content'];
                 }
                 $row['_post_date'] = ipsRegistry::getClass('class_localization')->getDate($row['post_date'], 'SHORT');
                 $row['_raw_date'] = $row['post_date'];
                 $row['_date_array'] = IPSTime::date_getgmdate($row['post_date'] + ipsRegistry::getClass('class_localization')->getTimeOffset());
                 $row['post'] .= "\n<!--IBF.ATTACHMENT_" . $row['pid'] . "-->";
                 $url = $this->registry->output->buildSEOUrl("showtopic={$row['topic_id']}&amp;view=findpost&amp;p={$row['pid']}", 'public', $row['title_seo'], 'showtopic');
                 $content .= $this->registry->getClass('output')->getTemplate('profile')->tabSingleColumn($row, $this->lang->words['profile_read_topic'], $url, $this->lang->words['profile_in_topic'] . $row['title']);
             }
             //-----------------------------------------
             // Attachments (but only if necessary)
             //-----------------------------------------
             if ($parseAttachments and !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();
                 if (IPSMember::checkPermissions('download') === false) {
                     $this->settings['show_img_upload'] = 0;
                 }
                 $content = $this->class_attach->renderAttachments($content, $pids);
                 $content = $content[0]['html'];
             }
             //-----------------------------------------
             // Macros...
             //-----------------------------------------
             $content = $this->registry->output->replaceMacros($content);
         }
     }
     //-----------------------------------------
     // Return content..
     //-----------------------------------------
     return $content ? $this->registry->getClass('output')->getTemplate('profile')->tabPosts($content) : $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_posts_to_show');
 }
示例#9
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);
 }
 /**
  * Post a reply
  * Very simply posts a reply. Simple.
  *
  * Usage:
  * $post->setFopicID(1);
  * $post->setTopicID(5);
  * $post->setPostID(100);
  * $post->setAuthor( $member );
  * 
  * $post->setPostContent( "Hello [b]there![/b]" );
  * # Optional: No bbcode, etc parsing will take place
  * # $post->setPostContentPreFormatted( "Hello <b>there!</b>" );
  * $post->editPost();
  *
  * Exception Error Codes:
  * NO_TOPIC_ID       : No topic ID set
  * NO_FORUM_ID		: No forum ID set
  * NO_AUTHOR_SET	    : No Author set
  * NO_CONTENT        : No post content set
  * CONTENT_TOO_LONG  : Post is too long
  * NO_SUCH_TOPIC     : No such topic
  * NO_SUCH_FORUM		: No such forum
  * NO_REPLY_PERM     : Author cannot reply to this topic
  * TOPIC_LOCKED		: The topic is locked
  * NO_REPLY_POLL     : Cannot reply to this poll only topic
  * TOPIC_LOCKED		: The topic is locked
  * NO_REPLY_POLL		: This is a poll only topic
  * NO_POST_FORUM		: Unable to post in that forum
  * FORUM_LOCKED		: Forum read only
  *
  * @access	public
  * @return	mixed
  */
 public function editPost()
 {
     //-----------------------------------------
     // Set up
     //-----------------------------------------
     $topic_id = intval($this->getTopicID());
     $forum_id = intval($this->getForumID());
     //-----------------------------------------
     // Global checks and functions
     //-----------------------------------------
     try {
         $this->globalSetUp();
     } catch (Exception $error) {
         $this->_postErrors = $error->getMessage();
     }
     if (!$this->getPostContent() and !$this->getPostContentPreFormatted()) {
         $this->_postErrors = 'NO_CONTENT';
     }
     //-----------------------------------------
     // Get topic
     //-----------------------------------------
     try {
         $topic = $this->editSetUp();
     } catch (Exception $error) {
         $this->_postErrors = $error->getMessage();
     }
     //-----------------------------------------
     // Parse the post, and check for any errors.
     //-----------------------------------------
     $post = $this->compilePostData();
     //-----------------------------------------
     // Do we have a valid post?
     //-----------------------------------------
     if (strlen(trim(IPSText::removeControlCharacters(IPSText::br2nl($post['post'])))) < 1) {
         $this->_postErrors = 'NO_CONTENT';
     }
     if (IPSText::mbstrlen($postContent) > $this->settings['max_post_length'] * 1024) {
         $this->_postErrors = 'CONTENT_TOO_LONG';
     }
     //-----------------------------------------
     // Ajax specifics
     //-----------------------------------------
     if ($this->getIsAjax() === TRUE) {
         # Prevent polls from being edited
         $this->can_add_poll = 0;
         # Prevent titles from being edited
         $this->edit_title = 0;
         # Set Settings
         $this->setSettings(array('enableSignature' => $this->_originalPost['use_sig'] ? 1 : 0, 'enableEmoticons' => $this->_originalPost['use_emo'] ? 1 : 0, 'post_htmlstatus' => intval($this->_originalPost['post_htmlstate'])));
         $this->request['iconid'] = $this->_originalPost['icon_id'];
         if (!$this->getAuthor('g_append_edit')) {
             $this->request['add_edit'] = ($this->_originalPost['append_edit'] or !$this->getAuthor('g_append_edit') ? 1 : 0);
         }
     }
     //-----------------------------------------
     // Compile the poll
     //-----------------------------------------
     if ($this->can_add_poll) {
         //-----------------------------------------
         // Load the poll from the DB
         //-----------------------------------------
         $this->poll_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'polls', 'where' => "tid=" . $topic['tid']));
         $this->DB->execute();
         $this->poll_answers = $this->poll_data['choices'] ? unserialize(stripslashes($this->poll_data['choices'])) : array();
     }
     //-----------------------------------------
     // Compile the poll
     //-----------------------------------------
     $this->poll_questions = $this->compilePollData();
     if ($this->_postErrors != "" or $this->getIsPreview() === TRUE) {
         //-----------------------------------------
         // Show the form again
         //-----------------------------------------
         return FALSE;
     }
     //-----------------------------------------
     // Grab the edit time
     //-----------------------------------------
     $time = ipsRegistry::getClass('class_localization')->getDate(time(), 'LONG');
     //-----------------------------------------
     // Reset some data
     //-----------------------------------------
     $post['ip_address'] = $this->_originalPost['ip_address'];
     $post['topic_id'] = $this->_originalPost['topic_id'];
     $post['author_id'] = $this->_originalPost['author_id'];
     $post['post_date'] = $this->_originalPost['post_date'];
     $post['author_name'] = $this->_originalPost['author_name'];
     $post['queued'] = $this->_originalPost['queued'];
     $post['edit_time'] = time();
     $post['edit_name'] = $this->getAuthor('members_display_name');
     //-----------------------------------------
     // If the post icon has changed, update the topic post icon
     //-----------------------------------------
     if ($this->_originalPost['new_topic'] == 1) {
         if ($post['icon_id'] != $this->_originalPost['icon_id']) {
             $this->DB->update('topics', array('icon_id' => $post['icon_id']), 'tid=' . $topic['tid']);
         }
     }
     //-----------------------------------------
     // Update open and close times
     //-----------------------------------------
     if ($this->_originalPost['new_topic'] == 1) {
         $times = array();
         if ($this->can_set_open_time and $this->times['open']) {
             $times['topic_open_time'] = intval($this->times['open']);
             if ($topic['topic_open_time'] and $this->times['open']) {
                 $times['state'] = "closed";
                 if (time() > $topic['topic_open_time']) {
                     if (time() < $topic['topic_close_time']) {
                         $times['state'] = "open";
                     }
                 }
             }
             if (!$this->times['open'] and $topic['topic_open_time']) {
                 if ($topic['state'] == 'closed') {
                     $times['state'] = 'open';
                 }
             }
         }
         if ($this->can_set_close_time and $this->times['close']) {
             $times['topic_close_time'] = intval($this->times['close']);
             //-----------------------------------------
             // Was a close time, but not now?
             //-----------------------------------------
             if (!$this->times['close'] and $topic['topic_close_time']) {
                 if ($topic['state'] == 'closed') {
                     $times['state'] = 'open';
                 }
             }
         }
         if (count($times)) {
             $this->DB->update('topics', $times, "tid=" . $topic['tid']);
         }
     }
     //-----------------------------------------
     // Update poll
     //-----------------------------------------
     if ($this->can_add_poll) {
         if (is_array($this->poll_questions) and count($this->poll_questions)) {
             $poll_only = 0;
             if ($this->settings['ipb_poll_only'] and $this->request['poll_only'] == 1) {
                 $poll_only = 1;
             }
             $poll_view_voters = !$this->poll_data['votes'] ? $this->request['poll_view_voters'] : $this->poll_data['poll_view_voters'];
             if ($topic['poll_state']) {
                 $this->DB->update('polls', array('votes' => intval($this->poll_total_votes), 'choices' => addslashes(serialize($this->poll_questions)), 'poll_question' => IPSText::stripAttachTag($this->request['poll_question']), 'poll_only' => $poll_only, 'poll_view_voters' => intval($poll_view_voters)), 'tid=' . $topic['tid']);
                 if ($this->poll_data['choices'] != serialize($this->poll_questions) or $this->poll_data['votes'] != intval($this->poll_total_votes)) {
                     $this->DB->insert('moderator_logs', array('forum_id' => $this->getForumData('id'), 'topic_id' => $topic['tid'], 'post_id' => $this->_originalPost['pid'], 'member_id' => $this->getAuthor('member_id'), 'member_name' => $this->getAuthor('members_display_name'), 'ip_address' => $this->ip_address, 'http_referer' => my_getenv('HTTP_REFERER'), 'ctime' => time(), 'topic_title' => $topic['title'], 'action' => "Edited poll", 'query_string' => my_getenv('QUERY_STRING')));
                 }
             } else {
                 $this->DB->insert('polls', array('tid' => $topic['tid'], 'forum_id' => $this->getForumData('id'), 'start_date' => time(), 'choices' => addslashes(serialize($this->poll_questions)), 'starter_id' => $this->getAuthor('member_id'), 'votes' => 0, 'poll_question' => IPSText::stripAttachTag($this->request['poll_question']), 'poll_only' => $poll_only, 'poll_view_voters' => intval($poll_view_voters)));
                 $this->DB->insert('moderator_logs', array('forum_id' => $this->getForumData('id'), 'topic_id' => $topic['tid'], 'post_id' => $this->_originalPost['pid'], 'member_id' => $this->getAuthor('member_id'), 'member_name' => $this->getAuthor('members_display_name'), 'ip_address' => $this->ip_address, 'http_referer' => my_getenv('HTTP_REFERER'), 'ctime' => time(), 'topic_title' => $topic['title'], 'action' => "Added a poll to the topic titled '" . $this->request['poll_question'] . "'", 'query_string' => my_getenv('QUERY_STRING')));
                 $this->DB->update('topics', array('poll_state' => 1, 'last_vote' => 0, 'total_votes' => 0), 'tid=' . $topic['tid']);
             }
         } else {
             //-----------------------------------------
             // Remove the poll
             //-----------------------------------------
             $this->DB->buildAndFetch(array('delete' => 'polls', 'where' => "tid=" . $topic['tid']));
             $this->DB->buildAndFetch(array('delete' => 'voters', 'where' => "tid=" . $topic['tid']));
             $this->DB->update('topics', array('poll_state' => 0, 'last_vote' => 0, 'total_votes' => 0), 'tid=' . $topic['tid']);
         }
     }
     //-----------------------------------------
     // Update topic title?
     //-----------------------------------------
     if ($this->edit_title == 1) {
         //-----------------------------------------
         // Update topic title
         //-----------------------------------------
         if ($this->_topicTitle != "") {
             if ($this->_topicTitle != $topic['title'] or $this->_topicDescription != $topic['description'] or !$topic['title_seo']) {
                 $this->DB->update('topics', array('title' => $this->_topicTitle, 'title_seo' => IPSText::makeSeoTitle($this->_topicTitle), 'description' => $this->_topicDescription), "tid=" . $topic['tid']);
                 if ($topic['tid'] == $this->getForumData('last_id')) {
                     $this->DB->update('forums', array('last_title' => $this->_topicTitle), 'id=' . $this->getForumData('id'));
                     //ipsRegistry::getClass('class_forums')->updateForumCache();
                 }
                 if ($this->moderator['edit_topic'] == 1 or $this->getAuthor('g_is_supmod') == 1) {
                     $this->DB->insert('moderator_logs', array('forum_id' => $this->getForumData('id'), 'topic_id' => $topic['tid'], 'post_id' => $this->_originalPost['pid'], 'member_id' => $this->getAuthor('member_id'), 'member_name' => $this->getAuthor('members_display_name'), 'ip_address' => $this->ip_address, 'http_referer' => my_getenv('HTTP_REFERER'), 'ctime' => time(), 'topic_title' => $topic['title'], 'action' => "Edited topic title or description '{$topic['title']}' to '" . $this->_topicTitle . "' via post form", 'query_string' => my_getenv('QUERY_STRING')));
                 }
             }
         }
     }
     //-----------------------------------------
     // Reason for edit?
     //-----------------------------------------
     if ($this->moderator['edit_post'] or $this->getAuthor('g_is_supmod')) {
         $post['post_edit_reason'] = trim($this->request['post_edit_reason']);
     }
     //-----------------------------------------
     // Update the database (ib_forum_post)
     //-----------------------------------------
     $post['append_edit'] = 1;
     if ($this->getAuthor('g_append_edit')) {
         if ($this->request['add_edit'] != 1) {
             $post['append_edit'] = 0;
         }
     }
     $this->DB->force_data_type = array('post_edit_reason' => 'string');
     $this->DB->update('posts', $post, 'pid=' . $this->_originalPost['pid']);
     if ($this->_originalPost['topic_firstpost']) {
         $pid = 0;
         $title = $r['title'];
     } else {
         $pid = serialize(array('pid' => $r['pid'], 'title' => $r['title']));
         $title = '';
     }
     /* Remove from the search index */
     $this->registry->class_forums->removePostFromSearchIndex($post['topic_id'], $this->_originalPost['pid'], $topic['posts'] ? 0 : 1);
     /* Update the search index */
     $topic_title = $this->_topicTitle ? $this->_topicTitle : $topic['title'];
     /* Add to cache */
     IPSContentCache::update($this->_originalPost['pid'], 'post', $this->formatPostForCache($post['post']));
     /* Upload Attachments */
     $this->uploadAttachments($this->post_key, $this->_originalPost['pid']);
     //-----------------------------------------
     // Make attachments "permanent"
     //-----------------------------------------
     $this->makeAttachmentsPermanent($this->post_key, $this->_originalPost['pid'], 'post', array('topic_id' => $topic['tid']));
     //-----------------------------------------
     // Make sure paperclip symbol is OK
     //-----------------------------------------
     $this->recountTopicAttachments($topic['tid']);
     //-----------------------------------------
     // Leave data for other apps
     //-----------------------------------------
     $this->setTopicData($topic);
     $this->setPostData(array_merge($this->_originalPost, $post));
     return TRUE;
 }
 /**
  * Manage validating members
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _manageValidating()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $ids = array();
     //-----------------------------------------
     // GET checkboxes
     //-----------------------------------------
     foreach ($this->request as $k => $v) {
         if (preg_match("/^mid_(\\d+)\$/", $k, $match)) {
             if ($v) {
                 $ids[] = $match[1];
             }
         }
     }
     $ids = IPSLib::cleanIntArray($ids);
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if (count($ids) < 1) {
         $this->registry->output->showError($this->lang->words['t_nomemsel'], 11247);
     }
     //-----------------------------------------
     // APPROVE
     //-----------------------------------------
     if ($this->request['type'] == 'approve') {
         IPSText::getTextClass('email')->getTemplate("complete_reg");
         $approved = array();
         //-----------------------------------------
         // Get members
         //-----------------------------------------
         $this->DB->build(array('select' => 'v.*', 'from' => array('validating' => 'v'), 'where' => "m.member_id IN(" . implode(",", $ids) . ")", 'add_join' => array(array('select' => 'm.member_id, m.members_display_name, m.name, m.email, m.member_group_id', 'from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id', 'type' => 'left'))));
         $main = $this->DB->execute();
         while ($row = $this->DB->fetch($main)) {
             $approved[] = $row['name'];
             //-----------------------------------------
             // Only approve if the user is validating
             //-----------------------------------------
             if ($row['member_group_id'] != $this->settings['auth_group']) {
                 continue;
             }
             //-----------------------------------------
             // Don't approve if no real_group set
             //-----------------------------------------
             if (!$row['real_group']) {
                 //$row['real_group'] = $this->settings['member_group'];
                 continue;
             }
             //-----------------------------------------
             // We don't approve lost pass requests
             //-----------------------------------------
             if ($row['lost_pass'] == 1) {
                 continue;
             }
             try {
                 IPSMember::save($row['member_id'], array('core' => array('member_group_id' => $row['real_group'])));
             } catch (Exception $error) {
                 $this->registry->output->showError($error->getMessage(), 11247);
             }
             IPSText::getTextClass('email')->buildMessage(array());
             //-----------------------------------------
             // Using 'name' on purpose
             // @see http://forums./index.php?autocom=tracker&showissue=11564&view=findpost&p=45269
             //-----------------------------------------
             IPSText::getTextClass('email')->subject = sprintf($this->lang->words['subject__complete_reg'], $row['name'], $this->settings['board_name']);
             IPSText::getTextClass('email')->to = $row['email'];
             IPSText::getTextClass('email')->sendMail();
             IPSLib::runMemberSync('onGroupChange', $row['member_id'], $row['real_group']);
         }
         $this->DB->delete('validating', "member_id IN(" . implode(",", $ids) . ")");
         ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($ids) . $this->lang->words['t_memregapp2'] . implode(", ", $approved));
         //-----------------------------------------
         // Stats to Update?
         //-----------------------------------------
         $this->cache->rebuildCache('stats', 'global');
         $this->registry->output->global_message = count($ids) . $this->lang->words['t_memregapp'];
         if ($this->request['_return']) {
             $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . 'app=members&module=members&section=members&do=viewmember&member_id=' . $this->request['_return']);
         }
         $this->_viewQueue('validating');
         return;
     } else {
         if ($this->request['type'] == 'resend') {
             $reset = array();
             $cant = array();
             $main_msgs = array();
             //-----------------------------------------
             // Get members
             //-----------------------------------------
             $this->DB->build(array('select' => 'v.*', 'from' => array('validating' => 'v'), 'where' => "m.member_id IN(" . implode(",", $ids) . ")", 'add_join' => array(array('select' => 'm.member_id, m.members_display_name, m.email, m.member_group_id', 'from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id', 'type' => 'left'))));
             $main = $this->DB->execute();
             while ($row = $this->DB->fetch($main)) {
                 if ($row['member_group_id'] != $this->settings['auth_group']) {
                     continue;
                 }
                 if ($row['lost_pass']) {
                     IPSText::getTextClass('email')->getTemplate("lost_pass");
                     IPSText::getTextClass('email')->buildMessage(array('NAME' => $row['members_display_name'], 'THE_LINK' => $this->settings['board_url'] . "/index.php?app=core&module=global&section=lostpass&do=sendform&uid=" . $row['member_id'] . "&aid=" . $val['vid'], 'MAN_LINK' => $this->settings['board_url'] . "/index.php?app=core&module=global&section=lostpass", 'EMAIL' => $row['email'], 'ID' => $row['member_id'], 'CODE' => $row['vid'], 'IP_ADDRESS' => $row['ip_address']));
                     IPSText::getTextClass('email')->subject = $this->lang->words['t_passwordrec'] . $this->settings['board_name'];
                     IPSText::getTextClass('email')->to = $row['email'];
                     IPSText::getTextClass('email')->sendMail();
                 } else {
                     if ($row['new_reg']) {
                         if ($row['user_verified']) {
                             $cant[] = $row['members_display_name'];
                             continue;
                         }
                         IPSText::getTextClass('email')->getTemplate("reg_validate");
                         IPSText::getTextClass('email')->buildMessage(array('THE_LINK' => $this->settings['board_url'] . "/index.php?app=core&module=global&section=register&do=auto_validate&uid=" . $row['member_id'] . "&aid=" . $row['vid'], 'NAME' => $row['members_display_name'], 'MAN_LINK' => $this->settings['board_url'] . "/index.php?app=core&module=global&section=register&do=05", 'EMAIL' => $row['email'], 'ID' => $row['member_id'], 'CODE' => $row['vid']));
                         IPSText::getTextClass('email')->subject = $this->lang->words['t_regat'] . $this->settings['board_name'];
                         IPSText::getTextClass('email')->to = $row['email'];
                         IPSText::getTextClass('email')->sendMail();
                     } else {
                         if ($row['email_chg']) {
                             IPSText::getTextClass('email')->getTemplate("newemail");
                             IPSText::getTextClass('email')->buildMessage(array('NAME' => $row['members_display_name'], 'THE_LINK' => $this->settings['board_url'] . "/index.php?app=core&module=global&section=register&do=auto_validate&type=newemail&uid=" . $row['member_id'] . "&aid=" . $row['vid'], 'ID' => $row['member_id'], 'MAN_LINK' => $this->settings['board_url'] . "/index.php?app=core&module=global&section=register&do=user_validate", 'CODE' => $row['vid']));
                             IPSText::getTextClass('email')->subject = $this->lang->words['t_emailchange'] . $this->settings['board_name'];
                             IPSText::getTextClass('email')->to = $row['email'];
                             IPSText::getTextClass('email')->sendMail();
                         }
                     }
                 }
                 $resent[] = $row['members_display_name'];
             }
             if (count($resent)) {
                 ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($resent) . $this->lang->words['tools_val_resent_log'] . implode(", ", $resent));
                 $main_msgs[] = count($resent) . $this->lang->words['t_vallog'] . implode(", ", $resent);
             }
             if (count($cant)) {
                 $main_msgs[] = $this->lang->words['t_valcannot'] . implode(", ", $cant);
             }
             $this->registry->output->global_message = count($main_msgs) ? implode("<br />", $main_msgs) : '';
             $this->_viewQueue('validating');
             return;
         } else {
             if ($this->request['type'] == 'ban') {
                 $this->DB->update('members', array('member_banned' => 1), "member_id IN(" . implode(",", $ids) . ")");
                 $this->DB->delete('validating', "member_id IN(" . implode(",", $ids) . ")");
                 ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($ids) . $this->lang->words['t_membanned']);
                 $this->registry->output->global_message = count($ids) . $this->lang->words['t_membanned'];
                 $this->_viewQueue('validating');
                 return;
             } else {
                 if ($this->request['type'] == 'spam') {
                     /* Grab members */
                     $members = IPSMember::load($ids);
                     /* Load moderator's library */
                     require IPSLib::getAppDir('forums') . '/sources/classes/moderate.php';
                     $modLibrary = new moderatorLibrary($this->registry);
                     /* Load custom fields class */
                     require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
                     $fields = new customProfileFields();
                     /* Load language file */
                     $this->registry->getClass('class_localization')->loadLanguageFile(array('public_mod'), 'forums');
                     foreach ($members as $member_id => $member) {
                         $toSave = array('core' => array('bw_is_spammer' => 1, 'member_group_id' => $this->settings['member_group']));
                         /* Protected group? */
                         if (strstr(',' . $this->settings['warn_protected'] . ',', ',' . $member['member_group_id'] . ',')) {
                             continue;
                         }
                         /* What do to.. */
                         if ($this->settings['spm_option']) {
                             switch ($this->settings['spm_option']) {
                                 case 'disable':
                                     $toSave['core']['restrict_post'] = 1;
                                     $toSave['core']['members_disable_pm'] = 2;
                                     break;
                                 case 'unapprove':
                                     $toSave['core']['restrict_post'] = 1;
                                     $toSave['core']['members_disable_pm'] = 2;
                                     /* Unapprove posts and topics */
                                     $modLibrary->toggleApproveMemberContent($member_id, FALSE, 'all', intval($this->settings['spm_post_days']) * 24);
                                     break;
                                 case 'ban':
                                     /* Unapprove posts and topics */
                                     $modLibrary->toggleApproveMemberContent($member_id, FALSE, 'all', intval($this->settings['spm_post_days']) * 24);
                                     $toSave = array('core' => array('member_banned' => 1, 'title' => '', 'bw_is_spammer' => 1), 'extendedProfile' => array('signature' => '', 'pp_bio_content' => '', 'pp_about_me' => '', 'pp_status' => ''));
                                     //-----------------------------------------
                                     // Avatar
                                     //-----------------------------------------
                                     $toSave['extendedProfile']['avatar_location'] = "";
                                     $toSave['extendedProfile']['avatar_size'] = "";
                                     try {
                                         IPSMember::getFunction()->removeAvatar($member['member_id']);
                                     } catch (Exception $e) {
                                         // Maybe should show an error or something
                                     }
                                     //-----------------------------------------
                                     // Photo
                                     //-----------------------------------------
                                     IPSMember::getFunction()->removeUploadedPhotos($member['member_id']);
                                     $toSave['extendedProfile'] = array_merge($toSave['extendedProfile'], array('pp_main_photo' => '', 'pp_main_width' => '', 'pp_main_height' => '', 'pp_thumb_photo' => '', 'pp_thumb_width' => '', 'pp_thumb_height' => ''));
                                     //-----------------------------------------
                                     // Profile fields
                                     //-----------------------------------------
                                     $fields->member_data = $member;
                                     $fields->initData('edit');
                                     $fields->parseToSave(array());
                                     if (count($fields->out_fields)) {
                                         $toSave['customFields'] = $fields->out_fields;
                                     }
                                     //-----------------------------------------
                                     // Update signature content cache
                                     //-----------------------------------------
                                     IPSContentCache::update($member['member_id'], 'sig', '');
                                     break;
                             }
                         }
                         /* Send an email */
                         if ($this->settings['spm_notify'] and $this->settings['email_out'] != $this->memberData['email']) {
                             IPSText::getTextClass('email')->getTemplate('possibleSpammer');
                             IPSText::getTextClass('email')->buildMessage(array('DATE' => $this->registry->class_localization->getDate($member['joined'], 'LONG', 1), 'MEMBER_NAME' => $member['members_display_name'], 'IP' => $member['ip_address'], 'EMAIL' => $member['email'], 'LINK' => $this->registry->getClass('output')->buildSEOUrl("showuser="******"member_id IN(" . implode(",", $ids) . ")");
                         $this->registry->output->global_message = count($ids) . ' ' . $this->lang->words['t_setasspammers'];
                         $this->_viewQueue('validating');
                         return;
                     }
                 } else {
                     $denied = array();
                     $this->DB->build(array('select' => 'members_display_name', 'from' => 'members', 'where' => "member_id IN(" . implode(",", $ids) . ")"));
                     $this->DB->execute();
                     while ($r = $this->DB->fetch()) {
                         $denied[] = $r['members_display_name'];
                     }
                     try {
                         IPSMember::remove($ids);
                     } catch (Exception $error) {
                         $this->registry->output->showError($error->getMessage(), 11247);
                     }
                     ipsRegistry::getClass('adminFunctions')->saveAdminLog(count($ids) . $this->lang->words['t_regdenied'] . implode(", ", $denied));
                     $this->registry->output->global_message = count($ids) . $this->lang->words['t_removedmem'];
                     $this->_viewQueue('validating');
                     return;
                 }
             }
         }
     }
 }
 /**
  * UserCP Save Form: Signature
  *
  * @access	public
  * @return	array	Errors
  */
 public function saveSignature()
 {
     //-----------------------------------------
     // Check to make sure that we can edit profiles..
     //-----------------------------------------
     $sig_restrictions = explode(':', $this->memberData['g_signature_limits']);
     if (!$this->memberData['g_edit_profile'] or $sig_restrictions[0] and !$this->memberData['g_sig_unit']) {
         $this->registry->getClass('output')->showError('members_profile_disabled', 1028);
     }
     //-----------------------------------------
     // Check length
     //-----------------------------------------
     if (IPSText::mbstrlen($_POST['Post']) > $this->settings['max_sig_length'] and $this->settings['max_sig_length']) {
         $this->registry->getClass('output')->showError('members_sig_too_long', 1029);
     }
     //-----------------------------------------
     // Remove board tags
     //-----------------------------------------
     $this->request['Post'] = IPSText::removeMacrosFromInput($this->request['Post']);
     //-----------------------------------------
     // Post process the editor
     // Now we have safe HTML and bbcode
     //-----------------------------------------
     $signature = IPSText::getTextClass('editor')->processRawPost('Post');
     //-----------------------------------------
     // Parse post
     //-----------------------------------------
     IPSText::getTextClass('bbcode')->parse_smilies = 0;
     IPSText::getTextClass('bbcode')->parse_html = intval($this->settings['sig_allow_html']);
     IPSText::getTextClass('bbcode')->parse_bbcode = intval($this->settings['sig_allow_ibc']);
     IPSText::getTextClass('bbcode')->parsing_section = 'signatures';
     $signature = IPSText::getTextClass('bbcode')->preDbParse($signature);
     $testSignature = IPSText::getTextClass('bbcode')->preDisplayParse($signature);
     if (IPSText::getTextClass('bbcode')->error != "") {
         $this->registry->getClass('output')->showError(IPSText::getTextClass('bbcode')->error, 10210);
     }
     //-----------------------------------------
     // Signature restrictions...
     //-----------------------------------------
     $sig_errors = array();
     //-----------------------------------------
     // Max number of images...
     //-----------------------------------------
     if ($sig_restrictions[1] !== '') {
         if (substr_count(strtolower($signature), "[img]") > $sig_restrictions[1]) {
             $sig_errors[] = sprintf($this->lang->words['sig_toomanyimages'], $sig_restrictions[1]);
         }
     }
     //-----------------------------------------
     // Max number of urls...
     //-----------------------------------------
     if ($sig_restrictions[4] !== '') {
         if (substr_count(strtolower($signature), "[url") > $sig_restrictions[4]) {
             $sig_errors[] = sprintf($this->lang->words['sig_toomanyurls'], $sig_restrictions[4]);
         } else {
             preg_match_all("#(^|\\s|>)((http|https|news|ftp)://\\w+[^\\s\\[\\]\\<]+)#is", $signature, $matches);
             if (count($matches[1]) > $sig_restrictions[4]) {
                 $sig_errors[] = sprintf($this->lang->words['sig_toomanyurls'], $sig_restrictions[4]);
             }
         }
     }
     //-----------------------------------------
     // Max number of lines of text...
     //-----------------------------------------
     if ($sig_restrictions[5] !== '') {
         $testSig = IPSText::getTextClass('bbcode')->wordWrap($signature, $this->settings['post_wordwrap'], '<br />');
         if (substr_count($testSig, "<br />") >= $sig_restrictions[5]) {
             $sig_errors[] = sprintf($this->lang->words['sig_toomanylines'], $sig_restrictions[5]);
         }
     }
     //-----------------------------------------
     // Now the crappy part..
     //-----------------------------------------
     if ($sig_restrictions[2] !== '' and $sig_restrictions[3] !== '') {
         preg_match_all("/\\[img\\](.+?)\\[\\/img\\]/i", $signature, $allImages);
         if (count($allImages[1])) {
             foreach ($allImages[1] as $foundImage) {
                 $imageProperties = @getimagesize($foundImage);
                 if (is_array($imageProperties) and count($imageProperties)) {
                     if ($imageProperties[0] > $sig_restrictions[2] or $imageProperties[1] > $sig_restrictions[3]) {
                         $sig_errors[] = sprintf($this->lang->words['sig_imagetoobig'], $foundImage, $sig_restrictions[2], $sig_restrictions[3]);
                     }
                 }
             }
         }
     }
     if (count($sig_errors)) {
         $this->registry->getClass('output')->showError(implode('<br />', $sig_errors), 10211);
     }
     //-----------------------------------------
     // Write it to the DB.
     //-----------------------------------------
     IPSMember::save($this->memberData['member_id'], array('extendedProfile' => array('signature' => $signature)));
     /* Update cache */
     IPSContentCache::update($this->memberData['member_id'], 'sig', $testSignature);
     return TRUE;
 }
示例#13
0
 /**
  * Save the member updates
  *
  * @return	@e void
  * @todo 	[Future] Determine what items should be editable and allow moderators to edit them
  */
 protected function _doEditMember()
 {
     $this->loadData();
     //-----------------------------------------
     // Check permissions
     //-----------------------------------------
     if (!$this->memberData['g_is_supmod']) {
         $this->registry->output->showError('mod_only_supermods', 10370, true, null, 403);
     }
     if (!$this->memberData['g_access_cp'] and $this->warn_member['g_access_cp']) {
         $this->registry->output->showError('mod_admin_edit', 3032, true, null, 403);
     }
     if ($this->request['auth_key'] != $this->member->form_hash) {
         $this->registry->output->showError('no_permission', 3032.1, null, null, 403);
     }
     //-----------------------------------------
     // Init
     //-----------------------------------------
     $editable = array();
     $isHtml = intval($this->request['sig_htmlstatus']);
     //-----------------------------------------
     // Signature and about me
     //-----------------------------------------
     /* Load parser */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
     $parser = new $classToLoad();
     $this->editor->setLegacyMode(false);
     //-----------------------------------------
     // Parse signature
     //-----------------------------------------
     /* Set content in editor */
     $this->editor->setAllowBbcode(true);
     $this->editor->setAllowSmilies(false);
     $this->editor->setIsHtml($this->caches['group_cache'][$this->warn_member['member_group_id']]['g_dohtml'] && $isHtml);
     $this->editor->setBbcodeSection('signatures');
     $signature = $this->editor->process($_POST['Post']);
     /* About Me */
     $aboutme = $this->editor->process($_POST['aboutme']);
     //-----------------------------------------
     // Add to array to save
     //-----------------------------------------
     $save['extendedProfile'] = array('signature' => $signature, 'pp_about_me' => $aboutme);
     $save['members'] = array('title' => $this->request['title']);
     //-----------------------------------------
     // Removing photo?
     //-----------------------------------------
     if ($this->request['photo'] == 1) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/member/photo.php', 'classes_member_photo');
         $photos = new $classToLoad($this->registry);
         $photos->remove($this->warn_member['member_id']);
     }
     //-----------------------------------------
     // Removing Restrictions?
     //-----------------------------------------
     if ($this->request['modpreview'] == 1) {
         $save['core']['mod_posts'] = 0;
     }
     if ($this->request['postingrestriction'] == 1) {
         $save['core']['restrict_post'] = 0;
     }
     if ($this->request['remove_suspension'] == 1) {
         $save['core']['temp_ban'] = 0;
     }
     //-----------------------------------------
     // Profile fields
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields');
     $fields = new $classToLoad();
     $fields->member_data = $this->warn_member;
     $fields->initData('edit');
     $fields->parseToSave($_POST);
     if (count($fields->out_fields)) {
         $save['customFields'] = $fields->out_fields;
     }
     //-----------------------------------------
     // Bitwise
     //-----------------------------------------
     if (isset($this->request['status_updates'])) {
         $bw = IPSBWOptions::thaw($this->warn_member['members_bitoptions'], 'members');
         $bw['bw_no_status_update'] = $this->request['status_updates'] ? 0 : 1;
         $save['core']['members_bitoptions'] = IPSBWOptions::freeze($bw, 'members');
     }
     //-----------------------------------------
     // Write it to the DB.
     //-----------------------------------------
     IPSMember::save($this->warn_member['member_id'], $save);
     //-----------------------------------------
     // Update signature content cache
     //-----------------------------------------
     /* Update cache */
     IPSContentCache::update($this->warn_member['member_id'], 'sig', $parser->display($signature));
     //-----------------------------------------
     // Add a mod log entry and redirect
     //-----------------------------------------
     $this->getModLibrary()->addModerateLog(0, 0, 0, 0, $this->lang->words['acp_edited_profile'] . " " . $this->warn_member['members_display_name']);
     $this->_redirect($this->lang->words['acp_edited_profile'] . " " . $this->warn_member['members_display_name']);
 }
 /**
  * Add a reply to a topic
  *
  * @access	public
  * @param	string 		Post contnet
  * @param 	array		Array of topic ids to apply this reply to
  * @param	boolean		Increment post count?
  * @return	boolean		Reply added
  * @todo 	[Future] Would better using the new posting libs so that topic subs, etc are triggered maybe.
  *			Though, do we really want topic subs triggered on a multi-mod?
  */
 public function topicAddReply($post = "", $tids = array(), $incpost = 0)
 {
     if ($post == "") {
         return false;
     }
     if (count($tids) < 1) {
         return false;
     }
     $post = array('author_id' => $this->memberData['member_id'], 'use_sig' => 1, 'use_emo' => 1, 'ip_address' => $this->member->ip_address, 'post_date' => time(), 'icon_id' => 0, 'post' => $post, 'author_name' => $this->memberData['members_display_name'], 'topic_id' => "", 'queued' => 0, 'post_htmlstate' => 2);
     //-----------------------------------------
     // Add posts...
     //-----------------------------------------
     $seen_fids = array();
     $add_posts = 0;
     foreach ($tids as $row) {
         $tid = intval($row[0]);
         $fid = intval($row[1]);
         $pa = array();
         $ta = array();
         if (!in_array($fid, $seen_fids)) {
             $seen_fids[] = $fid;
         }
         if ($tid and $fid) {
             $pa = $post;
             $pa['topic_id'] = $tid;
             $this->DB->insert('posts', $pa);
             $_pid = $this->DB->getInsertId();
             /* Add to cache */
             IPSContentCache::update($_pid, 'post', $post['post'], FALSE);
             $ta = array('last_poster_id' => $this->memberData['member_id'], 'last_poster_name' => $this->memberData['members_display_name'], 'seo_last_name' => IPSText::makeSeoTitle($this->memberData['members_display_name']), 'last_post' => $pa['post_date']);
             $this->DB->force_data_type = array('last_poster_name' => 'string', 'seo_last_name' => 'string');
             $this->DB->buildAndFetch(array('update' => 'topics', 'set' => $this->DB->compileUpdateString($ta) . ", posts=posts+1", 'where' => 'tid=' . $tid));
             $add_posts++;
             //-----------------------------------------
             // Mark as read for current viewer
             //-----------------------------------------
             $this->registry->classItemMarking->markRead(array('forumID' => $fid, 'itemID' => $tid));
         }
     }
     if ($this->auto_update != false) {
         if (count($seen_fids) > 0) {
             foreach ($seen_fids as $id) {
                 $this->forumRecount($id);
             }
         }
     }
     if ($add_posts > 0) {
         $this->cache->rebuildCache('stats', 'global');
         //-----------------------------------------
         // Update current members stuff
         //-----------------------------------------
         $pcount = "";
         $member_group_id = "";
         if ($this->forum['inc_postcount'] and $incpost != 0) {
             //-----------------------------------------
             // Increment the users post count
             //-----------------------------------------
             $pcount = "posts=posts+" . $add_posts . ", ";
             //-----------------------------------------
             // Are we checking for auto promotion?
             //-----------------------------------------
             if ($this->memberData['g_promotion'] != '-1&-1') {
                 list($gid, $gposts) = explode('&', $this->memberData['g_promotion']);
                 if ($gid > 0 and $gposts > 0) {
                     if ($this->memberData['posts'] + $add_posts >= $gposts) {
                         $member_group_id = "member_group_id='{$gid}', ";
                     }
                 }
             }
         }
         $this->DB->buildAndFetch(array('update' => 'members', 'set' => $pcount . $member_group_id . "last_post=" . time(), 'where' => "member_id=" . $this->memberData['member_id']));
     }
     return true;
 }
 /**
  * Save the member updates
  *
  * @access	private
  * @return	void		Outputs error screen
  * @todo 	[Future] Determine what items should be editable and allow moderators to edit them
  */
 private function _doEditMember()
 {
     $member = $this->_checkAndGetMember();
     /* Get the signature */
     $signature = IPSText::getTextClass('editor')->processRawPost('Post');
     $aboutme = IPSText::getTextClass('editor')->processRawPost('aboutme');
     /* Parse the signature */
     IPSText::getTextClass('bbcode')->parse_smilies = 0;
     IPSText::getTextClass('bbcode')->parse_html = intval($this->settings['sig_allow_html']);
     IPSText::getTextClass('bbcode')->parse_bbcode = intval($this->settings['sig_allow_ibc']);
     IPSText::getTextClass('bbcode')->parsing_section = 'signatures';
     IPSText::getTextClass('bbcode')->parsing_mgroup = $member['member_group_id'];
     IPSText::getTextClass('bbcode')->parsing_mgroup_others = $member['mgroup_others'];
     $signature = IPSText::getTextClass('bbcode')->preDbParse($signature);
     /* Parse the about me */
     IPSText::getTextClass('bbcode')->parse_smilies = $this->settings['aboutme_emoticons'];
     IPSText::getTextClass('bbcode')->parse_html = intval($this->settings['aboutme_html']);
     IPSText::getTextClass('bbcode')->parse_bbcode = intval($this->settings['aboutme_bbcode']);
     IPSText::getTextClass('bbcode')->parsing_section = 'aboutme';
     IPSText::getTextClass('bbcode')->parsing_mgroup = $member['member_group_id'];
     IPSText::getTextClass('bbcode')->parsing_mgroup_others = $member['mgroup_others'];
     $aboutme = IPSText::getTextClass('bbcode')->preDbParse($aboutme);
     /* Add sig to the save array */
     $save['extendedProfile'] = array('signature' => $signature, 'pp_status' => trim($this->request['status']), 'pp_about_me' => $aboutme);
     $save['members'] = array('title' => $this->request['title']);
     if ($this->request['avatar'] == 1) {
         $save['extendedProfile']['avatar_location'] = "";
         $save['extendedProfile']['avatar_size'] = "";
         try {
             IPSMember::getFunction()->removeAvatar($member['member_id']);
         } catch (Exception $e) {
             // Maybe should show an error or something
         }
     }
     if ($this->request['photo'] == 1) {
         IPSMember::getFunction()->removeUploadedPhotos($member['member_id']);
         $save['extendedProfile'] = array_merge($save['extendedProfile'], array('pp_main_photo' => '', 'pp_main_width' => '', 'pp_main_height' => '', 'pp_thumb_photo' => '', 'pp_thumb_width' => '', 'pp_thumb_height' => ''));
     }
     //-----------------------------------------
     // Profile fields
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
     $fields = new customProfileFields();
     $fields->member_data = $member;
     $fields->initData('edit');
     $fields->parseToSave($_POST);
     if (count($fields->out_fields)) {
         $save['customFields'] = $fields->out_fields;
     }
     //-----------------------------------------
     // Write it to the DB.
     //-----------------------------------------
     IPSMember::save($member['member_id'], $save);
     //-----------------------------------------
     // Update signature content cache
     //-----------------------------------------
     IPSContentCache::update($member['member_id'], 'sig', $save['extendedProfile']['signature']);
     //-----------------------------------------
     // Add a mod log entry and redirect
     //-----------------------------------------
     $this->_addModeratorLog($this->lang->words['acp_edited_profile'] . " {$member['members_display_name']}");
     $this->registry->output->redirectScreen($this->lang->words['acp_edited_profile'] . " {$member['members_display_name']}", $this->settings['base_url'] . "app=forums&amp;module=moderate&amp;section=moderate&do=editmember&auth_key={$this->member->form_hash}&mid={$member['member_id']}");
 }