/**
  * Build member's bitwise field
  *
  * @access	public
  * @param	mixed		Either an array of member data or a member ID
  * @return	array
  */
 public static function buildBitWiseOptions($member)
 {
     //-----------------------------------------
     // Load the member?
     //-----------------------------------------
     if (!is_array($member) and $member == intval($member)) {
         $member = self::load($member, 'core,extendedProfile');
     }
     /* Unpack bitwise fields */
     $_tmp = IPSBWOptions::thaw($member['members_bitoptions'], 'members', 'global');
     if (count($_tmp)) {
         foreach ($_tmp as $k => $v) {
             /* Trigger notice if we have DB field */
             if (isset($member[$k])) {
                 trigger_error("Thawing bitwise options for MEMBERS: Bitwise field '{$k}' has overwritten DB field '{$k}'", E_USER_WARNING);
             }
             $member[$k] = $v;
         }
     }
     return $member;
 }
示例#2
0
 /**
  * Compiles all the incoming information into an array which is returned to the accessor
  *
  * @return	array
  */
 protected function compilePostData()
 {
     //-----------------------------------------
     // Sort out post content
     //-----------------------------------------
     if ($this->getPostContentPreFormatted()) {
         $postContent = $this->getPostContentPreFormatted();
     } else {
         $postContent = $this->formatPost($this->getPostContent());
     }
     //-----------------------------------------
     // Need to format the post?
     //-----------------------------------------
     $bw = array();
     if (!empty($this->_originalPost['pid'])) {
         $_tmp = IPSBWOptions::thaw($this->_originalPost['post_bwoptions'], 'posts', 'forums');
         if (count($_tmp)) {
             foreach ($_tmp as $k => $v) {
                 $bw[$k] = $v;
             }
         }
     }
     $bw['bw_post_from_mobile'] = intval($this->member->isMobileApp);
     $post = array('author_id' => $this->getAuthor('member_id') ? $this->getAuthor('member_id') : 0, 'use_sig' => intval($this->getSettings('enableSignature')), 'use_emo' => intval($this->getSettings('enableEmoticons')), 'ip_address' => $this->member->ip_address, 'post_date' => $this->getDate() ? $this->getDate() : IPS_UNIX_TIME_NOW, 'post' => $postContent, 'author_name' => $this->getAuthor('member_id') ? $this->getAuthor('members_display_name') : (empty($this->request['UserName']) ? $this->getAuthor('members_display_name') : $this->request['UserName']), 'topic_id' => 0, 'queued' => $this->getPublished() ? 0 : 1, 'post_htmlstate' => intval($this->getSettings('post_htmlstatus')), 'post_bwoptions' => IPSBWOptions::freeze($bw, 'posts', 'forums'));
     //-----------------------------------------
     // If we had any errors, parse them back to this class
     // so we can track them later.
     //-----------------------------------------
     if ($post['post_htmlstate'] != 1 && is_array($this->editor->getParsingErrors()) && count($this->editor->getParsingErrors())) {
         /* Should extend this to accept many */
         $errors = $this->editor->getParsingErrors();
         $this->_postErrors = array_pop($errors);
     }
     return $post;
 }
 /**
  * Show the add/edit form
  *
  * @param	string		[add|edit]
  * @return	@e void		[Outputs to screen]
  */
 public function modForm($type = 'add')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $group = array();
     if ($type == 'add') {
         /* Form Data */
         $mod_type = $this->request['group'] ? 'group' : 'name';
         $mod = array();
         $names = array();
         $forum_id = explode(',', $this->request['fid']);
         //-----------------------------------------
         // Start proper
         //-----------------------------------------
         $button = $this->lang->words['mod_addthis'];
         $form_code = 'doadd';
         if ($this->request['group']) {
             $this->DB->build(array('select' => 'g_id, g_title', 'from' => 'groups', 'where' => "g_id=" . intval($this->request['group'])));
             $this->DB->execute();
             if (!($group = $this->DB->fetch())) {
                 $this->registry->output->showError($this->lang->words['mod_nogroup'], 11327);
             }
         } else {
             if (!$this->request['member_id']) {
                 $this->registry->output->showError($this->lang->words['mod_memid'], 11328);
             } else {
                 $this->DB->build(array('select' => 'members_display_name, member_id', 'from' => 'members', 'where' => 'member_id=' . intval($this->request['member_id'])));
                 $this->DB->execute();
                 if (!($mem = $this->DB->fetch())) {
                     $this->registry->output->showError($this->lang->words['mod_memid'], 11329);
                 }
                 $member_id = $mem['member_id'];
                 $member_name = $mem['members_display_name'];
             }
         }
         //-----------------------------------------
         // Are they already a moderator?
         //-----------------------------------------
         $existingForums = array();
         $existingForumsByRecord = array();
         $this->DB->build(array('select' => '*', 'from' => 'moderators', 'where' => isset($member_id) ? "member_id={$member_id}" : "group_id={$group['g_id']}"));
         $this->DB->execute();
         while ($row = $this->DB->fetch()) {
             $exploded = array_filter(explode(',', $row['forum_id']), create_function('$v', 'return (bool) $v;'));
             $existingForums = array_merge($existingForums, $exploded);
             foreach ($exploded as $fid) {
                 $existingForumsByRecord[$fid] = $row['mid'];
             }
         }
         $alreadyAMod = array_intersect($forum_id, $existingForums);
         $notCurrentlyAMod = array_diff($forum_id, $existingForums);
         if (!empty($alreadyAMod) and empty($notCurrentlyAMod)) {
             // All of the forums we have selected we are already a moderator of
             // Are they all in the same record?
             $recordId = NULL;
             foreach ($forum_id as $fid) {
                 if ($recordId === NULL or $recordId == $existingForumsByRecord[$fid]) {
                     $recordId = $existingForumsByRecord[$fid];
                 } else {
                     $this->registry->output->showError('mod_all_selected_mod_already', 11332);
                     return;
                 }
             }
             $this->registry->output->silentRedirect($this->settings['base_url'] . "app=forums&section=moderator&act=mod&do=edit&mid={$recordId}&return_id={$recordId}");
         } elseif (!empty($alreadyAMod)) {
             $_alreadyAMod = array();
             $_alreadyAModByRecord = array();
             foreach ($alreadyAMod as $id) {
                 $_alreadyAMod[$id] = $this->registry->class_forums->forum_by_id[$id]['name'];
                 $_alreadyAModByRecord[$existingForumsByRecord[$id]][$id] = $this->registry->class_forums->forum_by_id[$id]['name'];
             }
             $_notCurrentlyAMod = array();
             foreach ($notCurrentlyAMod as $id) {
                 $_notCurrentlyAMod[$id] = $this->registry->class_forums->forum_by_id[$id]['name'];
             }
             $this->registry->output->html .= $this->html->moderatorDuplicateForm($mod_type, $mod_type == 'name' ? IPSMember::load($member_id) : $group, $_alreadyAMod, $_notCurrentlyAMod, $_alreadyAModByRecord);
             return;
         }
     } else {
         /* Check the moderator */
         if ($this->request['mid'] == "") {
             $this->registry->output->showError($this->lang->words['mod_valid'], 11330);
         }
         /* Form bits */
         $button = $this->lang->words['mod_edithis'];
         $form_code = "doedit";
         /* Moderator Info */
         $this->DB->build(array('select' => '*', 'from' => 'moderators', 'where' => "mid=" . intval($this->request['mid'])));
         $this->DB->execute();
         if (!($mod = $this->DB->fetch())) {
             $this->registry->output->showError($this->lang->words['mod_mid'], 11331);
         }
         /* BW Options */
         $_tmp = IPSBWOptions::thaw($mod['mod_bitoptions'], 'moderators', 'forums');
         if (count($_tmp)) {
             foreach ($_tmp as $k => $v) {
                 $mod[$k] = $v;
             }
         }
         /* Other */
         $forum_id = explode(',', IPSText::cleanPermString($mod['forum_id']));
         $member_id = $mod['member_id'];
         $member_name = $mod['member_name'];
         $mod_type = $mod['is_group'] ? 'group' : 'name';
     }
     /* Form Fields */
     $mod['edit_post'] = $this->registry->output->formYesNo('edit_post', $mod['edit_post']);
     $mod['edit_topic'] = $this->registry->output->formYesNo('edit_topic', $mod['edit_topic']);
     $mod['delete_post'] = $this->registry->output->formYesNo('delete_post', $mod['delete_post']);
     $mod['delete_topic'] = $this->registry->output->formYesNo('delete_topic', $mod['delete_topic']);
     $mod['view_ip'] = $this->registry->output->formYesNo('view_ip', $mod['view_ip']);
     $mod['open_topic'] = $this->registry->output->formYesNo('open_topic', $mod['open_topic']);
     $mod['close_topic'] = $this->registry->output->formYesNo('close_topic', $mod['close_topic']);
     $mod['move_topic'] = $this->registry->output->formYesNo('move_topic', $mod['move_topic']);
     $mod['pin_topic'] = $this->registry->output->formYesNo('pin_topic', $mod['pin_topic']);
     $mod['unpin_topic'] = $this->registry->output->formYesNo('unpin_topic', $mod['unpin_topic']);
     $mod['split_merge'] = $this->registry->output->formYesNo('split_merge', $mod['split_merge']);
     $mod['mod_can_set_open_time'] = $this->registry->output->formYesNo('mod_can_set_open_time', $mod['mod_can_set_open_time']);
     $mod['mod_can_set_close_time'] = $this->registry->output->formYesNo('mod_can_set_close_time', $mod['mod_can_set_close_time']);
     $mod['mass_move'] = $this->registry->output->formYesNo('mass_move', $mod['mass_move']);
     $mod['mass_prune'] = $this->registry->output->formYesNo('mass_prune', $mod['mass_prune']);
     $mod['topic_q'] = $this->registry->output->formYesNo('topic_q', $mod['topic_q']);
     $mod['post_q'] = $this->registry->output->formYesNo('post_q', $mod['post_q']);
     $mod['allow_warn'] = $this->registry->output->formYesNo('allow_warn', $mod['allow_warn']);
     $mod['can_mm'] = $this->registry->output->formYesNo('can_mm', $mod['can_mm']);
     $mod['bw_flag_spammers'] = $this->registry->output->formYesNo('bw_flag_spammers', $mod['bw_flag_spammers']);
     $mod['bw_can_toggle_answered_post'] = $this->registry->output->formYesNo('bw_can_toggle_answered_post', $mod['bw_can_toggle_answered_post']);
     $mod['forums'] = $this->registry->output->formMultiDropdown('forums[]', $this->registry->getClass('class_forums')->adForumsForumList(1), $forum_id);
     $mod['bw_mod_soft_delete'] = $this->registry->output->formYesNo("bw_mod_soft_delete", $mod['bw_mod_soft_delete']);
     $mod['bw_mod_un_soft_delete'] = $this->registry->output->formYesNo("bw_mod_un_soft_delete", $mod['bw_mod_un_soft_delete']);
     $mod['bw_mod_soft_delete_see'] = $this->registry->output->formYesNo("bw_mod_soft_delete_see", $mod['bw_mod_soft_delete_see']);
     /* Output */
     $this->registry->output->extra_nav[] = array('', $this->lang->words['mod_' . $type]);
     $this->registry->output->html .= $this->html->moderatorPermissionForm($mod, $form_code, $mod['mid'], $member_id, $mod_type, $group['g_id'], $group['g_name'], $button);
 }
 /**
  * Returns a list of all forums
  *
  * @return	array
  */
 public function getForumList()
 {
     /* Get the forums */
     $this->DB->build(array('select' => 'f.*', 'from' => array('forums' => 'f'), 'add_join' => array(array('select' => 'p.*', 'from' => array('permission_index' => 'p'), 'where' => "p.perm_type='forum' AND p.app='forums' AND p.perm_type_id=f.id", 'type' => 'left'), $this->registry->classItemMarking->getSqlJoin(array('item_app_key_1' => 'f.id')))));
     $q = $this->DB->execute();
     /* Loop through and build an array of forums */
     $forums_list = array();
     $update_seo = array();
     $tempForums = array();
     while ($f = $this->DB->fetch($q)) {
         $tempForums[$f['parent_id'] . '.' . $f['position'] . '.' . $f['id']] = $f;
     }
     /* Sort in PHP */
     $tempForums = IPSLib::knatsort($tempForums);
     foreach ($tempForums as $posData => $f) {
         $fr = array();
         /* Add back into topic markers */
         $f = $this->registry->classItemMarking->setFromSqlJoin($f, 'forums');
         /**
          * This is here in case the SEO name isn't stored for some reason.
          * We'll parse it and then update the forums table - should only happen once
          */
         if (!$f['name_seo']) {
             /* SEO name */
             $f['name_seo'] = IPSText::makeSeoTitle($f['name']);
             $update_seo[$f['id']] = $f['name_seo'];
         }
         /* Reformat the array for a category */
         if ($f['parent_id'] == -1) {
             $fr = $f;
             $fr['parent_id'] = 'root';
             $fr['hide_last_info'] = 0;
             $fr['can_view_others'] = 0;
         } else {
             $fr = $f;
             $fr['description'] = isset($f['description']) ? $f['description'] : '';
         }
         $fr = array_merge($fr, $this->registry->permissions->parse($f));
         /* Unpack bitwise fields */
         $_tmp = IPSBWOptions::thaw($fr['forums_bitoptions'], 'forums', 'forums');
         if (count($_tmp)) {
             foreach ($_tmp as $k => $v) {
                 /* Trigger notice if we have DB field */
                 if (isset($fr[$k])) {
                     trigger_error("Thawing bitwise options for FORUMS: Bitwise field '{$k}' has overwritten DB field '{$k}'", E_USER_WARNING);
                 }
                 $fr[$k] = $v;
             }
         }
         /* Add... */
         $forums_list[$fr['id']] = $fr;
     }
     $this->allForums = $forums_list;
     /**
      * Update forums table if SEO name wasn't cached yet
      */
     if (count($update_seo)) {
         foreach ($update_seo as $k => $v) {
             $this->DB->update('forums', array('name_seo' => $v), 'id=' . $k);
         }
     }
     return $forums_list;
 }
示例#5
0
 /**
  * Function to resync a member's Vkontakte data
  *
  * @access	public
  * @param	mixed		Member Data in an array form (result of IPSMember::load( $id, 'all' ) ) or a member ID
  * @return	array 		Updated member data	
  *
  * EXCEPTION CODES:
  * NO_MEMBER		Member ID does not exist
  * NOT_LINKED		Member ID or data specified is not linked to a FB profile
  */
 public function syncMember($memberData)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $exProfile = array();
     /* Do we need to load a member? */
     if (!is_array($memberData)) {
         $memberData = IPSMember::load(intval($memberData), 'all');
     }
     /* Got a member? */
     if (!$memberData['member_id']) {
         throw new Exception('NO_MEMBER');
     }
     /* Linked account? */
     if (!$memberData['vk_uid']) {
         throw new Exception('NOT_LINKED');
     }
     /* Not completed sign up ( no display name ) 
     		if ( $memberData['member_group_id'] == $this->settings['auth_group'] )
     		{
     			return false;
     		}
     		*/
     /* Thaw Options */
     $bwOptions = IPSBWOptions::thaw($memberData['vk_bwoptions'], 'vkontakte');
     /* Grab the data */
     try {
         $this->resetApi($memberData['vk_token'], $memberData['vk_uid']);
         if ($this->isConnected()) {
             $user = $this->fetchUserData();
             /* Load library */
             if ($bwOptions['vc_s_pic']) {
                 $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/member/photo.php', 'classes_member_photo');
                 $photo = new $classToLoad($this->registry);
                 $photo->save($memberData, 'vkontakte');
             }
         }
     } catch (Exception $e) {
     }
     return $memberData;
 }
示例#6
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;
 }
 /**
  * Show the add/edit form
  *
  * @access	public
  * @param	string		[add|edit]
  * @return	void		[Outputs to screen]
  */
 public function modForm($type = 'add')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $group = array();
     if ($type == 'add') {
         /* Form Data */
         $mod_type = $this->request['group'] ? 'group' : 'name';
         $mod = array();
         $names = array();
         $forum_id = explode(',', $this->request['fid']);
         //-----------------------------------------
         // Start proper
         //-----------------------------------------
         $button = $this->lang->words['mod_addthis'];
         $form_code = 'doadd';
         if ($this->request['group']) {
             $this->DB->build(array('select' => 'g_id, g_title', 'from' => 'groups', 'where' => "g_id=" . intval($this->request['group'])));
             $this->DB->execute();
             if (!($group = $this->DB->fetch())) {
                 $this->registry->output->showError($this->lang->words['mod_nogroup'], 11327);
             }
         } else {
             if (!$this->request['member_id']) {
                 $this->registry->output->showError($this->lang->words['mod_memid'], 11328);
             } else {
                 $this->DB->build(array('select' => 'members_display_name, member_id', 'from' => 'members', 'where' => 'member_id=' . intval($this->request['member_id'])));
                 $this->DB->execute();
                 if (!($mem = $this->DB->fetch())) {
                     $this->registry->output->showError($this->lang->words['mod_memid'], 11329);
                 }
                 $member_id = $mem['member_id'];
                 $member_name = $mem['members_display_name'];
             }
         }
     } else {
         /* Check the moderator */
         if ($this->request['mid'] == "") {
             $this->registry->output->showError($this->lang->words['mod_valid'], 11330);
         }
         /* Form bits */
         $button = $this->lang->words['mod_edithis'];
         $form_code = "doedit";
         /* Moderator Info */
         $this->DB->build(array('select' => '*', 'from' => 'moderators', 'where' => "mid=" . intval($this->request['mid'])));
         $this->DB->execute();
         if (!($mod = $this->DB->fetch())) {
             $this->registry->output->showError($this->lang->words['mod_mid'], 11331);
         }
         /* BW Options */
         $_tmp = IPSBWOptions::thaw($mod['mod_bitoptions'], 'moderators', 'forums');
         if (count($_tmp)) {
             foreach ($_tmp as $k => $v) {
                 $mod[$k] = $v;
             }
         }
         /* Other */
         $forum_id = explode(',', IPSText::cleanPermString($mod['forum_id']));
         $member_id = $mod['member_id'];
         $member_name = $mod['member_name'];
         $mod_type = $mod['is_group'] ? 'group' : 'name';
     }
     /* Form Fields */
     $mod['edit_post'] = $this->registry->output->formYesNo('edit_post', $mod['edit_post']);
     $mod['edit_topic'] = $this->registry->output->formYesNo('edit_topic', $mod['edit_topic']);
     $mod['delete_post'] = $this->registry->output->formYesNo('delete_post', $mod['delete_post']);
     $mod['delete_topic'] = $this->registry->output->formYesNo('delete_topic', $mod['delete_topic']);
     $mod['view_ip'] = $this->registry->output->formYesNo('view_ip', $mod['view_ip']);
     $mod['open_topic'] = $this->registry->output->formYesNo('open_topic', $mod['open_topic']);
     $mod['close_topic'] = $this->registry->output->formYesNo('close_topic', $mod['close_topic']);
     $mod['move_topic'] = $this->registry->output->formYesNo('move_topic', $mod['move_topic']);
     $mod['pin_topic'] = $this->registry->output->formYesNo('pin_topic', $mod['pin_topic']);
     $mod['unpin_topic'] = $this->registry->output->formYesNo('unpin_topic', $mod['unpin_topic']);
     $mod['split_merge'] = $this->registry->output->formYesNo('split_merge', $mod['split_merge']);
     $mod['mod_can_set_open_time'] = $this->registry->output->formYesNo('mod_can_set_open_time', $mod['mod_can_set_open_time']);
     $mod['mod_can_set_close_time'] = $this->registry->output->formYesNo('mod_can_set_close_time', $mod['mod_can_set_close_time']);
     $mod['mass_move'] = $this->registry->output->formYesNo('mass_move', $mod['mass_move']);
     $mod['mass_prune'] = $this->registry->output->formYesNo('mass_prune', $mod['mass_prune']);
     $mod['topic_q'] = $this->registry->output->formYesNo('topic_q', $mod['topic_q']);
     $mod['post_q'] = $this->registry->output->formYesNo('post_q', $mod['post_q']);
     $mod['allow_warn'] = $this->registry->output->formYesNo('allow_warn', $mod['allow_warn']);
     $mod['can_mm'] = $this->registry->output->formYesNo('can_mm', $mod['can_mm']);
     $mod['bw_flag_spammers'] = $this->registry->output->formYesNo('bw_flag_spammers', $mod['bw_flag_spammers']);
     $mod['forums'] = $this->registry->output->formMultiDropdown('forums[]', $this->registry->getClass('class_forums')->adForumsForumList(1), $forum_id);
     /* Output */
     $this->registry->output->html .= $this->html->moderatorPermissionForm($mod, $form_code, $mod['mid'], $member_id, $mod_type, $group['g_id'], $group['g_name'], $button);
 }
示例#8
0
 /**
  * Function to resync a member's Facebook data
  *
  * @access	public
  * @param	mixed		Member Data in an array form (result of IPSMember::load( $id, 'all' ) ) or a member ID
  * @return	array 		Updated member data	
  *
  * EXCEPTION CODES:
  * NO_MEMBER		Member ID does not exist
  * NOT_LINKED		Member ID or data specified is not linked to a FB profile
  */
 public function syncMember($memberData)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $exProfile = array();
     /* Do we need to load a member? */
     if (!is_array($memberData)) {
         $memberData = IPSMember::load(intval($memberData), 'all');
     }
     /* Got a member? */
     if (!$memberData['member_id']) {
         throw new Exception('NO_MEMBER');
     }
     /* Linked account? */
     if (!$memberData['fb_uid']) {
         throw new Exception('NOT_LINKED');
     }
     /* Thaw Options */
     $bwOptions = IPSBWOptions::thaw($memberData['fb_bwoptions'], 'facebook');
     /* Grab the data */
     try {
         $this->resetApi($memberData['fb_token'], $memberData['fb_uid']);
         if ($this->isConnected()) {
             $user = $this->fetchUserData();
             /* Load library */
             if ($bwOptions['fbc_s_pic']) {
                 $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/member/photo.php', 'classes_member_photo');
                 $photo = new $classToLoad($this->registry);
                 $photo->save($memberData, 'facebook');
             }
             if ($bwOptions['fbc_si_status'] and (isset($memberData['gbw_no_status_import']) and !$memberData['gbw_no_status_import']) and !$memberData['bw_no_status_update']) {
                 /* Fetch timeline */
                 //$memberData['tc_last_sid_import'] = ( $memberData['tc_last_sid_import'] < 1 ) ? 100 : $memberData['tc_last_sid_import'];
                 $_updates = $this->fetchUserTimeline($user['id'], 0, true);
                 /* Got any? */
                 if (count($_updates)) {
                     $update = array_shift($_updates);
                     if (is_array($update) and isset($update['message'])) {
                         /* @link	http://community.invisionpower.com/tracker/issue-27746-video-in-facebook-status */
                         $update['message'] = strip_tags($update['message']);
                         /* Load status class */
                         if (!$this->registry->isClassLoaded('memberStatus')) {
                             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/member/status.php', 'memberStatus');
                             $this->registry->setClass('memberStatus', new $classToLoad(ipsRegistry::instance()));
                         }
                         /* Set Author */
                         $this->registry->getClass('memberStatus')->setAuthor($memberData);
                         $this->registry->getClass('memberStatus')->setStatusOwner($memberData);
                         /* Convert if need be */
                         if (IPS_DOC_CHAR_SET != 'UTF-8') {
                             $update['message'] = IPSText::utf8ToEntities($update['message']);
                         }
                         /* Set Content */
                         $this->registry->getClass('memberStatus')->setContent(trim(IPSText::getTextClass('bbcode')->stripBadWords($update['message'])));
                         /* Set as imported */
                         $this->registry->getClass('memberStatus')->setIsImport(1);
                         /* Set creator */
                         $this->registry->getClass('memberStatus')->setCreator('facebook');
                         /* Can we reply? */
                         if ($this->registry->getClass('memberStatus')->canCreate()) {
                             $this->registry->getClass('memberStatus')->create();
                             //$exProfile['tc_last_sid_import'] = $update['id'];
                         }
                     }
                 }
             }
             /* Update member */
             IPSMember::save($memberData['member_id'], array('core' => array('fb_lastsync' => time()), 'extendedProfile' => $exProfile));
             /* merge and return */
             $memberData['fb_lastsync'] = time();
             $memberData = array_merge($memberData, $exProfile);
         } else {
             /* Update member even if it failed so it's not selected on next task run */
             IPSMember::save($memberData['member_id'], array('core' => array('fb_lastsync' => time())));
         }
     } catch (Exception $e) {
         /* Update member even if it failed so it's not selected on next task run */
         IPSMember::save($memberData['member_id'], array('core' => array('fb_lastsync' => time())));
         $this->registry->output->logErrorMessage($e->getMessage(), 'FB-EXCEPTION');
     }
     return $memberData;
 }
示例#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);
 }
示例#10
0
 /**
  * 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']);
 }
示例#11
0
 /**
  * Function to resync a member's Twitter data
  *
  * @access	public
  * @param	mixed		Member Data in an array form (result of IPSMember::load( $id, 'all' ) ) or a member ID
  * @return	array 		Updated member data	
  *
  * EXCEPTION CODES:
  * NO_MEMBER		Member ID does not exist
  * NOT_LINKED		Member ID or data specified is not linked to a FB profile
  */
 public function syncMember($memberData)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $exProfile = array();
     /* Do we need to load a member? */
     if (!is_array($memberData)) {
         $memberData = IPSMember::load(intval($memberData), 'all');
     }
     /* Got a member? */
     if (!$memberData['member_id']) {
         throw new Exception('NO_MEMBER');
     }
     /* Linked account? */
     if (!$memberData['twitter_id']) {
         throw new Exception('NOT_LINKED');
     }
     /* Not completed sign up ( no display name ) */
     if ($memberData['member_group_id'] == $this->settings['auth_group']) {
         return false;
     }
     /* Thaw Options */
     $bwOptions = IPSBWOptions::thaw($memberData['tc_bwoptions'], 'twitter');
     /* Grab the data */
     try {
         $this->resetApi($memberData['twitter_token'], $memberData['twitter_secret']);
         if ($this->isConnected()) {
             $user = $this->fetchUserData();
             /* Load library */
             if ($bwOptions['tc_s_pic']) {
                 $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/member/photo.php', 'classes_member_photo');
                 $photo = new $classToLoad($this->registry);
                 $photo->save($memberData, 'twitter');
             }
             if ($bwOptions['tc_s_aboutme']) {
                 $exProfile['pp_about_me'] = IPSText::getTextClass('bbcode')->stripBadWords(IPSText::convertCharsets($user['description'], 'utf-8', IPS_DOC_CHAR_SET));
             }
             if ($bwOptions['tc_si_status'] and (isset($memberData['gbw_no_status_import']) and !$memberData['gbw_no_status_import']) and !$memberData['bw_no_status_update']) {
                 /* Fetch timeline */
                 $memberData['tc_last_sid_import'] = $memberData['tc_last_sid_import'] < 1 ? 100 : $memberData['tc_last_sid_import'];
                 $_updates = $this->fetchUserTimeline($user['id'], $memberData['tc_last_sid_import'], true);
                 /* Got any? */
                 if (count($_updates)) {
                     $update = array_shift($_updates);
                     if (is_array($update) and isset($update['text'])) {
                         /* Load status class */
                         if (!$this->registry->isClassLoaded('memberStatus')) {
                             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/member/status.php', 'memberStatus');
                             $this->registry->setClass('memberStatus', new $classToLoad(ipsRegistry::instance()));
                         }
                         /* Set Author */
                         $this->registry->getClass('memberStatus')->setAuthor($memberData);
                         $this->registry->getClass('memberStatus')->setStatusOwner($memberData);
                         /* Convert if need be */
                         if (IPS_DOC_CHAR_SET != 'UTF-8') {
                             $update['text'] = IPSText::utf8ToEntities($update['text']);
                         }
                         /* Set Content */
                         $this->registry->getClass('memberStatus')->setContent(trim(IPSText::getTextClass('bbcode')->stripBadWords($update['text'])));
                         /* Set as imported */
                         $this->registry->getClass('memberStatus')->setIsImport(1);
                         /* Set creator */
                         $this->registry->getClass('memberStatus')->setCreator('twitter');
                         /* Can we reply? */
                         if ($this->registry->getClass('memberStatus')->canCreate()) {
                             $this->registry->getClass('memberStatus')->create();
                             $exProfile['tc_last_sid_import'] = $update['id'];
                         }
                     }
                 }
             }
             /* Allowed profile customization? */
             if ($bwOptions['tc_s_bgimg'] and ($user['profile_background_image_url'] or $user['profile_background_color']) and ($this->memberData['gbw_allow_customization'] and !$this->memberData['bw_disable_customization'])) {
                 /* remove bg images */
                 IPSMember::getFunction()->removeUploadedBackgroundImages($memberData['member_id']);
                 $exProfile['pp_customization'] = serialize(array('bg_url' => $user['profile_background_image_url'], 'type' => $user['profile_background_image_url'] ? 'url' : 'color', 'bg_color' => IPSText::alphanumericalClean($user['profile_background_color']), 'bg_tile' => intval($user['profile_background_tile'])));
             }
             /* Update member */
             IPSMember::save($memberData['member_id'], array('core' => array('tc_lastsync' => time()), 'extendedProfile' => $exProfile));
             /* merge and return */
             $memberData['tc_lastsync'] = time();
             $memberData = array_merge($memberData, $exProfile);
         }
     } catch (Exception $e) {
     }
     return $memberData;
 }
 /**
  * UserCP Save Form: Ignore Users
  *
  * @access	public
  * @return	array	Errors
  */
 public function saveFacebook()
 {
     if (!IPSLib::fbc_enabled()) {
         $this->registry->getClass('output')->showError('fbc_disabled', 1005);
     }
     //-----------------------------------------
     // Data
     //-----------------------------------------
     $toSave = IPSBWOptions::thaw($this->memberData['members_bitoptions'], 'members');
     //-----------------------------------------
     // Loop and save... simple
     //-----------------------------------------
     foreach (array('fbc_s_pic', 'fbc_s_avatar', 'fbc_s_status', 'fbc_s_aboutme') as $field) {
         $toSave[$field] = intval($this->request[$field]);
     }
     IPSMember::save($this->memberData['member_id'], array('extendedProfile' => array('fb_bwoptions' => IPSBWOptions::freeze($toSave, 'facebook'))));
     //-----------------------------------------
     // Now sync
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/facebook/connect.php';
     $facebook = new facebook_connect($this->registry);
     try {
         $facebook->syncMember($this->memberData);
     } catch (Exception $error) {
         $msg = $error->getMessage();
         switch ($msg) {
             case 'NOT_LINKED':
             case 'NO_MEMBER':
                 break;
         }
     }
     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']);
 }
 /**
  * Uploads a new photo for the member [process]
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _memberNewPhoto()
 {
     if (!$this->request['member_id']) {
         $this->registry->output->showError($this->lang->words['m_specify'], 11224);
     }
     $member = IPSMember::load($this->request['member_id']);
     //-----------------------------------------
     // Allowed to upload pics for administrators?
     //-----------------------------------------
     if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_photo_admin')) {
         $this->registry->output->global_message = $this->lang->words['m_noupload'];
         $this->_memberView();
         return;
     }
     $status = IPSMember::getFunction()->uploadPhoto(intval($this->request['member_id']));
     if ($status['status'] == 'fail') {
         switch ($status['error']) {
             case 'upload_failed':
                 $this->registry->output->showError($this->lang->words['m_upfailed'], 11225);
                 break;
             case 'invalid_file_extension':
                 $this->registry->output->showError($this->lang->words['m_invfileext'], 11226);
                 break;
             case 'upload_to_big':
                 $this->registry->output->showError($this->lang->words['m_thatswhatshesaid'], 11227);
                 break;
         }
     } else {
         $bwOptions = IPSBWOptions::thaw($member['fb_bwoptions'], 'facebook');
         $bwOptions['fbc_s_pic'] = 0;
         IPSMember::save($this->request['member_id'], array('extendedProfile' => array('pp_main_photo' => $status['final_location'], 'pp_main_width' => $status['final_width'], 'pp_main_height' => $status['final_height'], 'pp_thumb_photo' => $status['t_final_location'], 'pp_thumb_width' => $status['t_final_width'], 'pp_thumb_height' => $status['t_final_height'], 'fb_photo' => '', 'fb_photo_thumb' => '', 'fb_bwoptions' => IPSBWOptions::freeze($bwOptions, 'facebook'))));
         //-----------------------------------------
         // Redirect
         //-----------------------------------------
         $this->registry->output->doneScreen($this->lang->words['m_photoupdated'], $this->lang->words['m_search'], "{$this->form_code}&amp;do=viewmember&amp;member_id={$this->request['member_id']}", "redirect");
     }
 }
 /**
  * Function to resync a member's FB data
  *
  * @access	public
  * @param	mixed		Member Data in an array form (result of IPSMember::load( $id, 'all' ) ) or a member ID
  * @return	array 		Updated member data	
  *
  * EXCEPTION CODES:
  * NO_MEMBER		Member ID does not exist
  * NOT_LINKED		Member ID or data specified is not linked to a FB profile
  */
 public function syncMember($memberData)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $exProfile = array();
     /* Do we need to load a member? */
     if (!is_array($memberData)) {
         $memberData = IPSMember::load(intval($memberData), 'all');
     }
     /* Got a member? */
     if (!$memberData['member_id']) {
         throw new Exception('NO_MEMBER');
     }
     /* Linked account? */
     if (!$memberData['fb_uid']) {
         throw new Exception('NOT_LINKED');
     }
     /* Thaw Options */
     $bwOptions = IPSBWOptions::thaw($memberData['fb_bwoptions'], 'facebook');
     /* Grab the data */
     try {
         $_fbData = $this->API()->users_getInfo($memberData['fb_uid'], array('first_name', 'last_name', 'name', 'status', 'pic', 'pic_square', 'pic_square_with_logo', 'about_me', 'email_hashes'));
         $fbData = $_fbData[0];
         /* Format data */
         $emailHash = (is_array($fbData['email_hashes']) and $fbData['email_hashes'][0]) ? $fbData['email_hashes'][0] : $memberData['fb_emailhash'];
         /* Update.. */
         $exProfile['fb_photo'] = $bwOptions['fbc_s_pic'] ? $fbData['pic'] : '';
         $exProfile['fb_photo_thumb'] = $bwOptions['fbc_s_pic'] ? strstr($memberData['email'], '@proxymail.facebook.com') ? $fbData['pic_square_with_logo'] : $fbData['pic_square'] : '';
         if ($bwOptions['fbc_s_avatar']) {
             $exProfile['avatar_location'] = $fbData['pic_square'];
             $exProfile['avatar_type'] = 'facebook';
         }
         if ($bwOptions['fbc_s_aboutme']) {
             $exProfile['pp_about_me'] = IPSText::convertCharsets($fbData['about_me'], 'utf-8', IPS_DOC_CHAR_SET);
         }
         if ($bwOptions['fbc_s_status'] and is_array($fbData['status']) and $fbData['status']['message']) {
             $exProfile['pp_status'] = IPSText::convertCharsets($fbData['status']['message'], 'utf-8', IPS_DOC_CHAR_SET);
             $exProfile['pp_status_update'] = $fbData['status']['time'];
         }
         /* Update member */
         IPSMember::save($memberData['member_id'], array('core' => array('fb_emailhash' => $emailHash, 'fb_lastsync' => time()), 'extendedProfile' => $exProfile));
         /* merge and return */
         $memberData['fb_lastsync'] = time();
         $memberData = array_merge($memberData, $exProfile);
     } catch (Exception $e) {
     }
     return $memberData;
 }
 /**
  * Upload personal photo function
  * Assumes all security checks have been performed by this point
  *
  * @access	public
  * @param	integer		[Optional] member id instead of current member
  * @return 	array  		[ error (error message), status (status message [ok/fail] ) ]
  */
 public function uploadPhoto($member_id = 0)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $return = array('error' => '', 'status' => '', 'final_location' => '', 'final_width' => '', 'final_height' => '', 't_final_location' => '', 't_final_width' => '', 't_final_height' => '');
     $delete_photo = intval($_POST['delete_photo']);
     $member_id = $member_id ? intval($member_id) : intval($this->memberData['member_id']);
     $real_name = '';
     $upload_dir = '';
     $final_location = '';
     $final_width = '';
     $final_height = '';
     $t_final_location = '';
     $t_final_width = '';
     $t_final_height = '';
     $t_real_name = '';
     $t_height = 50;
     $t_width = 50;
     if (!$member_id) {
         return array('status' => 'cannot_find_member');
     }
     list($p_max, $p_width, $p_height) = explode(":", $this->memberData['g_photo_max_vars']);
     $this->settings['disable_ipbsize'] = 0;
     //-----------------------------------------
     // Sort out upload dir
     //-----------------------------------------
     /* Fix for bug 5075 */
     $this->settings['upload_dir'] = str_replace('&#46;', '.', $this->settings['upload_dir']);
     $upload_path = $this->settings['upload_dir'];
     # Preserve original path
     $_upload_path = $this->settings['upload_dir'];
     //-----------------------------------------
     // Already a dir?
     //-----------------------------------------
     if (!file_exists($upload_path . "/profile")) {
         if (@mkdir($upload_path . "/profile", 0777)) {
             @file_put_contents($upload_path . '/profile/index.html', '');
             @chmod($upload_path . "/profile", 0777);
             # Set path and dir correct
             $upload_path .= "/profile";
             $upload_dir = "profile/";
         } else {
             # Set path and dir correct
             $upload_dir = "";
         }
     } else {
         # Set path and dir correct
         $upload_path .= "/profile";
         $upload_dir = "profile/";
     }
     //-----------------------------------------
     // Deleting the photo?
     //-----------------------------------------
     if ($delete_photo) {
         $memberData = IPSMember::load($member_id);
         $bwOptions = IPSBWOptions::thaw($memberData['fb_bwoptions'], 'facebook');
         $bwOptions['fbc_s_pic'] = 0;
         $this->removeUploadedPhotos($member_id, $upload_path);
         IPSMember::save($member_id, array('extendedProfile' => array('pp_main_photo' => '', 'pp_main_width' => 0, 'pp_main_height' => 0, 'pp_thumb_photo' => '', 'pp_thumb_width' => 0, 'pp_thumb_height' => 0, 'fb_photo' => '', 'fb_photo_thumb' => '', 'fb_bwoptions' => IPSBWOptions::freeze($bwOptions, 'facebook'))));
         $return['status'] = 'deleted';
         return $return;
     }
     //-----------------------------------------
     // Lets check for an uploaded photo..
     //-----------------------------------------
     if ($_FILES['upload_photo']['name'] != "" and $_FILES['upload_photo']['name'] != "none") {
         //-----------------------------------------
         // Are we allowed to upload this photo?
         //-----------------------------------------
         if ($p_max < 0) {
             $return['status'] = 'fail';
             $return['error'] = 'no_photo_upload_permission';
         }
         //-----------------------------------------
         // Remove any uploaded photos...
         //-----------------------------------------
         $this->removeUploadedPhotos($member_id, $upload_path);
         $real_name = 'photo-' . $member_id;
         //-----------------------------------------
         // Load the library
         //-----------------------------------------
         require_once IPS_KERNEL_PATH . 'classUpload.php';
         $upload = new classUpload();
         //-----------------------------------------
         // Set up the variables
         //-----------------------------------------
         $upload->out_file_name = 'photo-' . $member_id;
         $upload->out_file_dir = $upload_path;
         $upload->max_file_size = $p_max * 1024 * 8;
         // Allow xtra for compression
         $upload->upload_form_field = 'upload_photo';
         //-----------------------------------------
         // Populate allowed extensions
         //-----------------------------------------
         if (is_array($this->cache->getCache('attachtypes')) and count($this->cache->getCache('attachtypes'))) {
             foreach ($this->cache->getCache('attachtypes') as $data) {
                 if ($data['atype_photo']) {
                     if ($data['atype_extension'] == 'swf' and $this->settings['disable_flash']) {
                         continue;
                     }
                     $upload->allowed_file_ext[] = $data['atype_extension'];
                 }
             }
         }
         //-----------------------------------------
         // Upload...
         //-----------------------------------------
         $upload->process();
         //-----------------------------------------
         // Error?
         //-----------------------------------------
         if ($upload->error_no) {
             switch ($upload->error_no) {
                 case 1:
                     // No upload
                     $return['status'] = 'fail';
                     $return['error'] = 'upload_failed';
                     break;
                 case 2:
                     // Invalid file ext
                     $return['status'] = 'fail';
                     $return['error'] = 'invalid_file_extension';
                     break;
                 case 3:
                     // Too big...
                     $return['status'] = 'fail';
                     $return['error'] = 'upload_to_big';
                     break;
                 case 4:
                     // Cannot move uploaded file
                     $return['status'] = 'fail';
                     $return['error'] = 'upload_failed';
                     break;
                 case 5:
                     // Possible XSS attack (image isn't an image)
                     $return['status'] = 'fail';
                     $return['error'] = 'upload_failed';
                     break;
             }
             return $return;
         }
         //-----------------------------------------
         // Still here?
         //-----------------------------------------
         $real_name = $upload->parsed_file_name;
         $t_real_name = $upload->parsed_file_name;
         //-----------------------------------------
         // Check image size...
         //-----------------------------------------
         if (!$this->settings['disable_ipbsize']) {
             $imageDimensions = getimagesize($upload_path . '/' . $real_name);
             if ($imageDimensions[0] > $p_width or $imageDimensions[1] > $p_height) {
                 //-----------------------------------------
                 // Main photo
                 //-----------------------------------------
                 require_once IPS_KERNEL_PATH . "classImage.php";
                 require_once IPS_KERNEL_PATH . "classImageGd.php";
                 $image = new classImageGd();
                 $image->init(array('image_path' => $upload_path, 'image_file' => $real_name));
                 $return = $image->resizeImage($p_width, $p_height);
                 $image->writeImage($upload_path . '/' . 'photo-' . $member_id . '.' . $upload->file_extension);
                 $t_real_name = $return['thumb_location'] ? $return['thumb_location'] : $real_name;
                 $im['img_width'] = $return['newWidth'] ? $return['newWidth'] : $image->cur_dimensions['width'];
                 $im['img_height'] = $return['newHeight'] ? $return['newHeight'] : $image->cur_dimensions['height'];
                 //-----------------------------------------
                 // MINI photo
                 //-----------------------------------------
                 $image->init(array('image_path' => $upload_path, 'image_file' => $t_real_name));
                 $return = $image->resizeImage($t_width, $t_height);
                 $image->writeImage($upload_path . '/' . 'photo-thumb-' . $member_id . '.' . $upload->file_extension);
                 $t_im['img_width'] = $return['newWidth'];
                 $t_im['img_height'] = $return['newHeight'];
                 $t_im['img_location'] = count($return) ? 'photo-thumb-' . $member_id . '.' . $upload->file_extension : $real_name;
             } else {
                 $im['img_width'] = $imageDimensions[0];
                 $im['img_height'] = $imageDimensions[1];
                 //-----------------------------------------
                 // Mini photo
                 //-----------------------------------------
                 $_data = IPSLib::scaleImage(array('max_height' => $t_height, 'max_width' => $t_width, 'cur_width' => $im['img_width'], 'cur_height' => $im['img_height']));
                 $t_im['img_width'] = $_data['img_width'];
                 $t_im['img_height'] = $_data['img_height'];
                 $t_im['img_location'] = $real_name;
             }
         } else {
             //-----------------------------------------
             // Main photo
             //-----------------------------------------
             $w = intval($this->request['man_width']) ? intval($this->request['man_width']) : $p_width;
             $h = intval($this->request['man_height']) ? intval($this->request['man_height']) : $p_height;
             $im['img_width'] = $w > $p_width ? $p_width : $w;
             $im['img_height'] = $h > $p_height ? $p_height : $h;
             //-----------------------------------------
             // Mini photo
             //-----------------------------------------
             $_data = IPSLib::scaleImage(array('max_height' => $t_height, 'max_width' => $t_width, 'cur_width' => $im['img_width'], 'cur_height' => $im['img_height']));
             $t_im['img_width'] = $_data['img_width'];
             $t_im['img_height'] = $_data['img_height'];
             $t_im['img_location'] = $real_name;
         }
         //-----------------------------------------
         // Check the file size (after compression)
         //-----------------------------------------
         if (filesize($upload_path . "/" . $real_name) > $p_max * 1024) {
             @unlink($upload_path . "/" . $real_name);
             // Too big...
             $return['status'] = 'fail';
             $return['error'] = 'upload_to_big';
             return $return;
         }
         //-----------------------------------------
         // Main photo
         //-----------------------------------------
         $final_location = $upload_dir . $real_name;
         $final_width = $im['img_width'];
         $final_height = $im['img_height'];
         //-----------------------------------------
         // Mini photo
         //-----------------------------------------
         $t_final_location = $upload_dir . $t_im['img_location'];
         $t_final_width = $t_im['img_width'];
         $t_final_height = $t_im['img_height'];
     } else {
         $return['status'] = 'ok';
         return $return;
     }
     //-----------------------------------------
     // Return...
     //-----------------------------------------
     $return['final_location'] = $final_location;
     $return['final_width'] = $final_width;
     $return['final_height'] = $final_height;
     $return['t_final_location'] = $t_final_location;
     $return['t_final_width'] = $t_final_width;
     $return['t_final_height'] = $t_final_height;
     $return['status'] = 'ok';
     return $return;
 }
示例#17
0
 /**
  * Uploads a new photo for the member [process]
  *
  * @return	@e void
  */
 protected function _memberNewPhoto()
 {
     if (!$this->request['member_id']) {
         $this->registry->output->showError($this->lang->words['m_specify'], 11224);
     }
     $member = IPSMember::load($this->request['member_id']);
     //-----------------------------------------
     // Allowed to upload pics for administrators?
     //-----------------------------------------
     if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_photo_admin')) {
         $this->registry->output->global_message = $this->lang->words['m_noupload'];
         $this->_memberView();
         return;
     }
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/member/photo.php', 'classes_member_photo');
     $photos = new $classToLoad($this->registry);
     $status = $photos->uploadPhoto(intval($this->request['member_id']));
     if ($status['status'] == 'fail') {
         switch ($status['error']) {
             default:
             case 'upload_failed':
                 $this->registry->output->showError($this->lang->words['m_upfailed'], 11225);
                 break;
             case 'invalid_file_extension':
                 $this->registry->output->showError($this->lang->words['m_invfileext'], 11226);
                 break;
             case 'upload_to_big':
                 $this->registry->output->showError($this->lang->words['m_thatswhatshesaid'], 11227);
                 break;
         }
     } else {
         $bwOptions = IPSBWOptions::thaw($member['fb_bwoptions'], 'facebook');
         $tcbwOptions = IPSBWOptions::thaw($member['tc_bwoptions'], 'twitter');
         $bwOptions['fbc_s_pic'] = 0;
         $tcbwOptions['tc_s_pic'] = 0;
         IPSMember::save($this->request['member_id'], array('extendedProfile' => array('pp_main_photo' => $status['final_location'], 'pp_main_width' => intval($status['final_width']), 'pp_main_height' => intval($status['final_height']), 'pp_thumb_photo' => $status['t_final_location'], 'pp_thumb_width' => intval($status['t_final_width']), 'pp_thumb_height' => intval($status['t_final_height']), 'pp_photo_type' => 'custom', 'pp_profile_update' => IPS_UNIX_TIME_NOW, 'fb_photo' => '', 'fb_photo_thumb' => '', 'fb_bwoptions' => IPSBWOptions::freeze($bwOptions, 'facebook'), 'tc_photo' => '', 'tc_bwoptions' => IPSBWOptions::freeze($tcbwOptions, 'twitter'))));
         //-----------------------------------------
         // Redirect
         //-----------------------------------------
         $this->registry->output->global_message = $this->lang->words['m_photoupdated'];
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&amp;do=viewmember&amp;member_id=' . $this->request['member_id']);
     }
 }
示例#18
0
 /**
  * Get photo type - mostly here to help legacy / upgrades
  * @param	mixed	INT or Array
  */
 public function getPhotoType($member)
 {
     if (is_integer($member)) {
         $member = IPSMember::load($member, 'all');
     } else {
         if (isset($member['member_id']) && !isset($member['pp_photo_type'])) {
             $member = IPSMember::load($member['member_id'], 'all');
         }
     }
     if (!empty($member['pp_photo_type'])) {
         return $member['pp_photo_type'];
     } else {
         $bwOptions = IPSBWOptions::thaw($member['fb_bwoptions'], 'facebook');
         $tcbwOptions = IPSBWOptions::thaw($member['tc_bwoptions'], 'twitter');
         if (!empty($member['pp_main_photo']) and (strpos($member['pp_main_photo'], 'http://') === false or strpos($member['pp_main_photo'], $this->settings['original_base_url']))) {
             return 'custom';
         }
         if ($bwOptions['fbc_s_pic']) {
             return 'facebook';
         }
         if ($tcbwOptions['tc_s_pic']) {
             return 'twitter';
         }
         if ($member['pp_gravatar']) {
             return 'gravatar';
         }
         return 'none';
     }
 }
 /**
  * UserCP Save Form: Settings
  *
  * @access	public
  * @param	array	Array of member / core_sys_login information (if we're editing)
  * @return	mixed	Array of errors / boolean true
  */
 public function saveFormSettings($member = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $timeZone = IPSText::alphanumericalClean($this->request['timeZone'], '+.');
     $dst_correct = intval($this->request['dst_correct']);
     //-----------------------------------------
     // RTE
     //-----------------------------------------
     if (!$this->settings['posting_allow_rte']) {
         $this->request['editorChoice'] = 0;
     }
     //-----------------------------------------
     // PM Settings: 2 means admin says no.
     //-----------------------------------------
     if ($this->memberData['members_disable_pm'] == 2) {
         $this->member->setProperty('members_disable_pm', 2);
     } else {
         $this->member->setProperty('members_disable_pm', intval($this->request['disableMessenger']));
     }
     //-----------------------------------------
     // Only one account per identity url
     //-----------------------------------------
     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<>" . $this->memberData['member_id']));
         if ($account['member_id']) {
             return array(0 => $this->lang->words['identity_url_assoc']);
         }
         //-----------------------------------------
         // Need to clean up identity URL a little
         //-----------------------------------------
         $identityUrl = trim($this->request['identity_url']);
         $identityUrl = rtrim($identityUrl, "/");
         if (!strpos($identityUrl, 'http://') === 0 and !strpos($identityUrl, 'https://') === 0) {
             $identityUrl = 'http://' . $identityUrl;
         }
     }
     /* Figure out BW options */
     $toSave = IPSBWOptions::thaw($this->memberData['members_bitoptions'], 'members');
     foreach (array('bw_vnc_type', 'bw_forum_result_type') as $field) {
         $toSave[$field] = intval($this->request[$field]);
     }
     IPSMember::save($this->memberData['member_id'], array('core' => array('hide_email' => intval($this->request['hide_email']), 'email_pm' => intval($this->request['pm_reminder']), 'allow_admin_mails' => intval($this->request['admin_send']), 'time_offset' => $timeZone, 'dst_in_use' => ($this->request['dstOption'] and intval($this->request['dstCheck']) == 0) ? intval($this->request['dstOption']) : 0, 'members_auto_dst' => intval($this->request['dstCheck']), 'members_disable_pm' => intval($this->memberData['members_disable_pm']), 'members_editor_choice' => $this->request['editorChoice'] ? 'rte' : 'std', 'member_uploader' => $this->request['member_uploader'] ? 'flash' : 'default', 'view_pop' => intval($this->request['showPMPopUp']), 'identity_url' => $identityUrl, 'members_bitoptions' => IPSBWOptions::freeze($toSave, 'members'))));
     return TRUE;
 }