Exemple #1
0
 /**
  * Main class entry point
  *
  * @param	object		ipsRegistry reference
  * @return	@e void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // Got sess ID and mem ID?
     //-----------------------------------------
     if (!$this->member->getProperty('member_id')) {
         $this->returnString("no");
     }
     //-----------------------------------------
     // Check that we have the key
     //-----------------------------------------
     if ($this->settings['ipb_reg_number']) {
         $this->settings['ipschat_account_key'] = $this->settings['ipb_reg_number'];
     }
     if (!$this->settings['ipschat_account_key']) {
         $this->returnString("no");
     }
     //-----------------------------------------
     // Can we access?
     //-----------------------------------------
     $access_groups = explode(",", $this->settings['ipschat_group_access']);
     $my_groups = array($this->memberData['member_group_id']);
     if ($this->memberData['mgroup_others']) {
         $my_groups = array_merge($my_groups, explode(",", IPSText::cleanPermString($this->memberData['mgroup_others'])));
     }
     $access_allowed = false;
     foreach ($my_groups as $group_id) {
         if (in_array($group_id, $access_groups)) {
             $access_allowed = 1;
             break;
         }
     }
     if (!$access_allowed) {
         $this->returnString("no");
     }
     if ($this->memberData['chat_banned']) {
         $this->returnString("no");
     }
     $permissions = 0;
     if ($this->settings['ipschat_mods']) {
         $mod_groups = explode(",", $this->settings['ipschat_mods']);
         foreach ($my_groups as $group_id) {
             if (in_array($group_id, $mod_groups)) {
                 $permissions = 1;
                 break;
             }
         }
     }
     if (!$permissions) {
         $this->returnString("no");
     }
     //-----------------------------------------
     // Ban member
     //-----------------------------------------
     IPSMember::save($this->request['id'], array('core' => array('chat_banned' => 1)));
     //-----------------------------------------
     // Something to return
     //-----------------------------------------
     $this->returnString("ok");
 }
 /**
  * Class entry point
  *
  * @access	public
  * @param	object		Registry reference
  * @return	void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $info = array();
     $id = intval($this->memberData['member_id']);
     //-----------------------------------------
     // Get HTML and skin
     //-----------------------------------------
     $this->registry->class_localization->loadLanguageFile(array('public_profile'), 'members');
     //-----------------------------------------
     // Can we access?
     //-----------------------------------------
     if (!$this->memberData['g_mem_info'] or $this->memberData['gbw_no_status_update']) {
         $this->returnJsonError($this->lang->words['status_off']);
     }
     if (!$id) {
         $this->returnJsonError($this->lang->words['status_off']);
     }
     $newStatus = trim(IPSText::getTextClass('bbcode')->stripBadWords(IPSText::parseCleanValue($_POST['new_status'])));
     IPSMember::save($id, array('extendedProfile' => array('pp_status' => $newStatus, 'pp_status_update' => time())));
     $this->returnJsonArray(array('status' => 'success', 'new_status' => $newStatus));
     exit;
 }
 /**
  * Class entry point
  *
  * @access	public
  * @param	object		Registry reference
  * @return	void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // Security check
     //-----------------------------------------
     if ($this->request['k'] != $this->member->form_hash) {
         $this->registry->getClass('output')->showError('no_permission', 20314);
     }
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $info = array();
     $id = intval($this->memberData['member_id']);
     //-----------------------------------------
     // Get HTML and skin
     //-----------------------------------------
     $this->registry->class_localization->loadLanguageFile(array('public_profile'), 'members');
     //-----------------------------------------
     // Can we access?
     //-----------------------------------------
     if (!$this->memberData['g_mem_info']) {
         $this->registry->output->showError('status_off', 10268);
     }
     if (!$id) {
         $this->registry->output->showError('status_off', 10269);
     }
     $newStatus = trim(IPSText::getTextClass('bbcode')->stripBadWords($this->request['new_status']));
     IPSMember::save($id, array('extendedProfile' => array('pp_status' => $newStatus, 'pp_status_update' => time())));
     $this->registry->output->redirectScreen($this->lang->words['status_was_changed'], $this->settings['base_url'] . 'showuser='******'members_seo_name']);
 }
 /**
  * Stores main facebook data
  *
  * @return	@e void		[Outputs JSON to browser AJAX call]
  */
 protected function _storeFacebookAuthDetails()
 {
     $rToken = trim($this->request['accessToken']);
     $rUserId = trim($this->request['userId']);
     # Do not INTVAL as Facebook UID > Intval() max
     /* Store it */
     IPSMember::save($this->memberData['member_id'], array('core' => array('fb_uid' => $rUserId, 'fb_token' => $rToken)));
     $this->returnJsonArray(array('status' => 'ok'));
 }
 /**
  * Main function executed automatically by the controller
  *
  * @param	object		$registry		Registry object
  * @return	@e void
  */
 public function doExecute(ipsRegistry $registry)
 {
     $member = IPSMember::load(intval($this->request['member']), 'none', 'id');
     if ($member['member_id'] and $this->request['key'] == md5($member['email'] . ':' . $member['members_pass_hash'])) {
         IPSMember::save($member['member_id'], array('members' => array('allow_admin_mails' => 0)));
         $this->registry->getClass('output')->addContent($this->registry->output->getTemplate('ucp')->unsubscribed());
         $this->registry->getClass('output')->sendOutput();
     }
     $this->registry->output->showError('email_no_unsubscribe');
 }
Exemple #6
0
 /**
  * Class entry point
  *
  * @param	object		Registry reference
  * @return	@e void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     if (!$this->memberData['member_id']) {
         $this->returnNull();
     }
     if ($this->memberData['members_auto_dst'] == 1 and $this->settings['time_dst_auto_correction']) {
         $newValue = $this->memberData['dst_in_use'] ? 0 : 1;
         IPSMember::save($this->memberData['member_id'], array('members' => array('dst_in_use' => $newValue)));
     }
     $this->returnNull();
 }
 /**
  * Changes the skin ID choice for the member
  *
  * @return	@e void
  */
 protected function _change()
 {
     $skinId = $this->request['skinId'];
     if ($this->request['skinId'] != 'setAsMobile' && $this->request['k'] != $this->member->form_hash) {
         $this->registry->output->showError('no_permission', 10122243, FALSE, '', 403);
     }
     if (is_numeric($skinId)) {
         /* Rudimentaty check */
         if ($this->registry->output->allSkins[$skinId]['_youCanUse'] and $this->registry->output->allSkins[$skinId]['_gatewayExclude'] !== TRUE) {
             if ($this->memberData['member_id']) {
                 /* Update... */
                 IPSMember::save($this->memberData['member_id'], array('core' => array('skin' => $skinId)));
             } else {
                 IPSCookie::set('guestSkinChoice', $skinId);
             }
             /* Make sure mobile skin is removed */
             IPSCookie::set("mobileApp", 'false', -1);
             IPSCookie::set("mobileBrowser", 0, -1);
             /* remove user agent bypass */
             IPSCookie::set("uagent_bypass", 0, -1);
             /* Update member row */
             $this->memberData['skin'] = $skinId;
         }
     } else {
         if ($skinId == 'fullVersion') {
             /* Set cookie */
             IPSCookie::set("uagent_bypass", 1, -1);
             IPSCookie::set("mobileBrowser", 0, -1);
         } else {
             if ($skinId == 'unlockUserAgent') {
                 $this->member->updateMySession(array('uagent_bypass' => 1));
                 /* Set cookie */
                 IPSCookie::set("uagent_bypass", 1, -1);
                 IPSCookie::set("mobileBrowser", 0, -1);
             } else {
                 if ($skinId == 'setAsMobile') {
                     $this->member->updateMySession(array('uagent_bypass' => 0));
                     /* Set cookie */
                     IPSCookie::set("uagent_bypass", 0, -1);
                     IPSCookie::set("mobileBrowser", 1, -1);
                 }
             }
         }
     }
     /* Redirect */
     if ($this->settings['query_string_real']) {
         $url = preg_replace('#&k=(?:\\S+?)($|&)#', '\\1', str_replace('&', '&', $this->settings['query_string_real']));
         $url = preg_replace('#&settingNewSkin=(?:\\S+?)($|&)#', '\\1', $url);
         $url = preg_replace('#&setAsMobile=(?:\\S+?)($|&)#', '\\1', $url);
         $this->registry->getClass('output')->silentRedirect($this->settings['board_url'] . '?' . $url, '', true);
     }
     $this->registry->getClass('output')->silentRedirect($this->settings['board_url'], '', true);
 }
 /**
  * Class entry point
  *
  * @access	public
  * @param	object		Registry reference
  * @return	void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     if (!$this->memberData['member_id']) {
         if ($this->request['xml']) {
             $this->returnNull();
         } else {
             $this->registry->output->silentRedirect($this->settings['base_url']);
         }
     }
     if ($this->memberData['members_auto_dst'] == 1 and $this->settings['time_dst_auto_correction']) {
         $newValue = $this->memberData['dst_in_use'] ? 0 : 1;
         IPSMember::save($this->memberData['member_id'], array('members' => array('dst_in_use' => $newValue)));
     }
     if ($this->request['xml'] == 1) {
         $this->returnNull();
     } else {
         $this->registry->output->silentRedirect($this->settings['base_url']);
     }
 }
Exemple #9
0
 /**
  * Remove a photo for a member
  * @param int $member_id
  * @return string
  */
 public function remove($member_id)
 {
     /* Fix up upload directory */
     $paths = $this->_getProfileUploadPaths();
     $upload_path = $paths['path'];
     $upload_dir = $paths['dir'];
     $memberData = IPSMember::load($member_id);
     $bwOptions = IPSBWOptions::thaw($memberData['fb_bwoptions'], 'facebook');
     $tcbwOptions = IPSBWOptions::thaw($memberData['tc_bwoptions'], 'twitter');
     $bwOptions['fbc_s_pic'] = 0;
     $tcbwOptions['tc_s_pic'] = 0;
     /* We should also disable Gravatar Bug #38739 */
     $memBitwise = IPSBWOptions::thaw($memberData['members_bitoptions'], 'members');
     $memBitwise['bw_disable_gravatar'] = 1;
     $memBitwise = IPSBWOptions::freeze($memBitwise, 'members');
     $this->removeUploadedPhotos($member_id, $upload_path);
     IPSMember::save($member_id, array('core' => array('members_bitoptions' => $memBitwise), 'extendedProfile' => array('pp_main_photo' => '', 'pp_main_width' => 0, 'pp_main_height' => 0, 'pp_thumb_photo' => '', 'pp_thumb_width' => 0, 'pp_thumb_height' => 0, 'pp_photo_type' => 'none', 'pp_gravatar' => '', 'fb_photo' => '', 'fb_photo_thumb' => '', 'fb_bwoptions' => IPSBWOptions::freeze($bwOptions, 'facebook'), 'tc_photo' => '', 'tc_bwoptions' => IPSBWOptions::freeze($tcbwOptions, 'twitter'))));
     return true;
 }
 /**
  * Shows the editor
  * print $editor->show( 'message', 'reply-topic-1244' );
  * @param	string	Field
  * @param	array   Options: Auto save key, a unique key for the page. If supplied, editor will auto-save at regular intervals. Works for logged in members only
  * @param	string	Optional content
  */
 public function show($fieldName, $options = array(), $content = '')
 {
     $showEditor = TRUE;
     /* Have we forced RTE? */
     if (!empty($this->request['isRte'])) {
         $options['isRte'] = intval($this->request['isRte']);
     }
     $_autoSaveKeyOrig = !empty($options['autoSaveKey']) ? $options['autoSaveKey'] : '';
     $options['editorName'] = !empty($options['editorName']) ? $options['editorName'] : $this->_fetchEditorName();
     $options['autoSaveKey'] = $_autoSaveKeyOrig && $this->memberData['member_id'] ? $this->_generateAutoSaveKey($_autoSaveKeyOrig) : '';
     $options['type'] = !empty($options['type']) && $options['type'] == 'mini' ? 'mini' : 'full';
     $options['minimize'] = intval($options['minimize']);
     $options['height'] = intval($options['height']);
     $options['isTypingCallBack'] = !empty($options['isTypingCallBack']) ? $options['isTypingCallBack'] : '';
     $options['noSmilies'] = !empty($options['noSmilies']) ? true : false;
     $options['delayInit'] = !empty($options['delayInit']) ? 1 : 0;
     $options['smilies'] = $this->fetchEmoticons();
     $options['bypassCKEditor'] = !empty($options['bypassCKEditor']) ? 1 : ($this->getRteEnabled() ? 0 : 1);
     $options['legacyMode'] = !empty($options['legacyMode']) ? $options['legacyMode'] : 'on';
     $html = '';
     /* Fetch disabled tags */
     $parser = $this->_newParserObject();
     $options['disabledTags'] = $parser->getDisabledTags();
     $this->setLegacyMode($options['legacyMode'] == 'on' ? true : false);
     if (isset($options['recover'])) {
         $content = $_POST['Post'];
     }
     /* Try and sniff out entered HTML */
     if (IN_ACP and empty($options['isHtml'])) {
         $options['isHtml'] = intval($this->_tryAndDetermineHtmlStatusTheHackyWay($content ? $content : $this->getContent()));
     }
     if (!empty($options['isHtml'])) {
         $this->setIsHtml(true);
         if (IN_ACP) {
             $options['type'] = 'ipsacp';
         }
     } else {
         if ($this->getIsHtml()) {
             $options['isHtml'] = 1;
         }
     }
     /* inline content */
     if ($content) {
         $this->setContent($this->getLegacyMode() ? str_replace('\\\'', '\'', $content) : $content);
     }
     /* Is this legacy bbcode?  If we are using RTE, we need to send HTML.
     			@link http://community.invisionpower.com/resources/bugs.html/_/ip-board/old-style-image-links-do-not-parse-in-editor-r42078 */
     if ($parser->isBBCode($this->getContent())) {
         $this->setContent($parser->htmlToEditor($this->getContent()));
     }
     /* Store last editor ID in case calling scripts need it */
     $this->settings['_lastEditorId'] = $options['editorName'];
     if (IN_ACP) {
         $html = $this->registry->getClass('output')->global_template->editor($fieldName, $this->getContent(), $options, $this->getAutoSavedContent($_autoSaveKeyOrig));
     } else {
         $warningInfo = '';
         $acknowledge = FALSE;
         //-----------------------------------------
         // Warnings
         //-----------------------------------------
         if (isset($options['warnInfo']) and $this->memberData['member_id']) {
             $message = '';
             /* Have they been restricted from posting? */
             if ($this->memberData['restrict_post']) {
                 $data = IPSMember::processBanEntry($this->memberData['restrict_post']);
                 if ($data['date_end']) {
                     if (time() >= $data['date_end']) {
                         IPSMember::save($this->memberData['member_id'], array('core' => array('restrict_post' => 0)));
                     } else {
                         $message = sprintf($this->lang->words['warnings_restrict_post_temp'], $this->lang->getDate($data['date_end'], 'JOINED'));
                     }
                 } else {
                     $message = $this->lang->words['warnings_restrict_post_perm'];
                 }
                 if ($this->memberData['unacknowledged_warnings']) {
                     $warn = ipsRegistry::DB()->buildAndFetch(array('select' => '*', 'from' => 'members_warn_logs', 'where' => "wl_member={$this->memberData['member_id']} AND wl_rpa<>0", 'order' => 'wl_date DESC', 'limit' => 1));
                     if ($warn['wl_id']) {
                         $moredetails = "<a href='javascript:void(0);' onclick='warningPopup( this, {$warn['wl_id']} )'>{$this->lang->words['warnings_moreinfo']}</a>";
                     }
                 }
                 if ($options['warnInfo'] == 'full') {
                     $this->registry->getClass('output')->showError("{$message} {$moredetails}", 103126, null, null, 403);
                 } else {
                     $showEditor = FALSE;
                 }
             }
             /* Nope? - Requires a new if in case time restriction got just removed */
             if (empty($message)) {
                 /* Do they have any warnings they have to acknowledge? */
                 if ($this->memberData['unacknowledged_warnings']) {
                     $unAcknowledgedWarns = ipsRegistry::DB()->buildAndFetch(array('select' => '*', 'from' => 'members_warn_logs', 'where' => "wl_member={$this->memberData['member_id']} AND wl_acknowledged=0", 'order' => 'wl_date DESC', 'limit' => 1));
                     if ($unAcknowledgedWarns['wl_id']) {
                         if ($options['warnInfo'] == 'full') {
                             $this->registry->getClass('output')->silentRedirect($this->registry->getClass('output')->buildUrl("app=members&amp;module=profile&amp;section=warnings&amp;do=acknowledge&amp;id={$unAcknowledgedWarns['wl_id']}"));
                         } else {
                             $this->lang->loadLanguageFile('public_profile', 'members');
                             $acknowledge = $unAcknowledgedWarns['wl_id'];
                         }
                     }
                 }
                 /* No? Are they on mod queue? */
                 if ($this->memberData['mod_posts']) {
                     $data = IPSMember::processBanEntry($this->memberData['mod_posts']);
                     if ($data['date_end']) {
                         if (time() >= $data['date_end']) {
                             IPSMember::save($this->memberData['member_id'], array('core' => array('mod_posts' => 0)));
                         } else {
                             $message = sprintf($this->lang->words['warnings_modqueue_temp'], $this->lang->getDate($data['date_end'], 'JOINED'));
                         }
                     } else {
                         $message = $this->lang->words['warnings_modqueue_perm'];
                     }
                     if ($message) {
                         $warn = ipsRegistry::DB()->buildAndFetch(array('select' => '*', 'from' => 'members_warn_logs', 'where' => "wl_member={$this->memberData['member_id']} AND wl_mq<>0", 'order' => 'wl_date DESC', 'limit' => 1));
                         if ($warn['wl_id']) {
                             if ($this->registry->output->getAsMobileSkin()) {
                                 $moredetails = "<a href='{$this->registry->getClass('output')->buildUrl("app=members&amp;module=profile&amp;section=warnings")}'>{$this->lang->words['warnings_moreinfo']}</a>";
                             } else {
                                 $moredetails = "<a href='javascript:void(0);' onclick='warningPopup( this, {$warn['wl_id']} )'>{$this->lang->words['warnings_moreinfo']}</a>";
                             }
                         }
                     }
                 }
                 /* How about our group? - Requires a new if in case mod queue restriction got just removed */
                 if (empty($message) && $this->memberData['g_mod_preview']) {
                     /* Do we only limit for x posts/days? */
                     if ($this->memberData['g_mod_post_unit']) {
                         if ($this->memberData['gbw_mod_post_unit_type']) {
                             /* Days.. .*/
                             if ($this->memberData['joined'] > time() - 86400 * $this->memberData['g_mod_post_unit']) {
                                 $message = sprintf($this->lang->words['ms_mod_q'] . ' ' . $this->lang->words['ms_mod_q_until'], $this->lang->getDate($this->memberData['joined'] + 86400 * $this->memberData['g_mod_post_unit'], 'long'));
                             }
                         } else {
                             /* Posts */
                             if ($this->memberData['posts'] < $this->memberData['g_mod_post_unit']) {
                                 $message = sprintf($this->lang->words['ms_mod_q'] . ' ' . $this->lang->words['ms_mod_q_until_posts'], $this->memberData['g_mod_post_unit'] - $this->memberData['posts']);
                             }
                         }
                     } else {
                         /* No limit, but still checking moderating */
                         $message = $this->lang->words['ms_mod_q'];
                     }
                 } elseif ($options['modAll'] and !$this->memberData['g_avoid_q']) {
                     $message = $this->lang->words['ms_mod_q'];
                 }
             }
             if ($message) {
                 $warningInfo = "{$message} {$moredetails}";
             }
         }
         //-----------------------------------------
         // Show the editor
         //-----------------------------------------
         $parser = new class_text_parser_legacy();
         $this->passSettings($parser);
         /* Mobile skin / app? */
         if ($this->_canWeRte(true) !== true || $this->registry->output->getAsMobileSkin()) {
             $content = $this->toPlainTextArea($this->getContent());
         } else {
             /* CKEditor decodes HTML entities */
             $content = str_replace('&', '&amp;', $this->getContent());
             /* Take a stab at fixing up manually entered CODE tag */
             //$content = $this->_fixManuallyEnteredCodeBoxesIntoRte( $content );
             /* Convert to BBCode for non JS peoples */
             $content = $parser->htmlToEditor($content);
         }
         $bbcodeVersion = '';
         if ($content) {
             $bbcodeVersion = $this->toPlainTextArea($parser->postEditor($content));
         }
         $html = $this->registry->getClass('output')->getTemplate('editors')->editor($fieldName, $content, $options, $this->getAutoSavedContent($_autoSaveKeyOrig), $warningInfo, $acknowledge, $bbcodeVersion, $showEditor);
     }
     return $html;
 }
 /**
  * Converge_Server::__create_user_session()
  *
  * Has to return at least the member ID, member log in key and session ID
  *
  * @access	protected
  * @param	object	$member		Member object (can access as an array of member information thx to SPL)
  * @return	array	$session	Session information
  * 
  * @deprecated	Doesn't seem to be used anymore, need to verify properly for the next major revision
  */
 protected function __create_user_session($member)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $update = array();
     //-----------------------------------------
     // Generate a new log in key
     //-----------------------------------------
     if (!$member['member_login_key']) {
         $update['member_login_key'] = IPSMember::generateAutoLoginKey();
     }
     //-----------------------------------------
     // Set our privacy status
     //-----------------------------------------
     $update['login_anonymous'] = '0&1';
     //-----------------------------------------
     // Update member?
     //-----------------------------------------
     if (is_array($update) and count($update)) {
         IPSMember::save($member['member_id'], array('core' => $update));
     }
     //-----------------------------------------
     // Still here? Create a new session
     //-----------------------------------------
     $this->registry->member()->setMember($member['member_id']);
     require_once IPS_ROOT_PATH . 'sources/classes/session/publicSessions.php';
     /*noLibHook*/
     require_once IPS_ROOT_PATH . 'sources/classes/session/convergeSessions.php';
     /*noLibHook*/
     $session = new convergeSessions($this->registry);
     $session->time_now = time();
     $update['publicSessionID'] = $session->createMemberSession();
     return array_merge($this->memberData, $update);
 }
 /**
  * Fetches the output
  *
  * @access	public
  * @param	string		Output gathered
  * @param	string		Title of the document
  * @param	array 		Navigation gathered
  * @param	array 		Array of document head items
  * @param	array 		Array of JS loader items
  * @param	array 		Array of extra data
  * @return	string		Output to be printed to the client
  */
 public function fetchOutput($output, $title, $navigation, $documentHeadItems, $jsLoaderItems, $extraData = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $system_vars_cache = $this->caches['systemvars'];
     $pmData = FALSE;
     $notificationLatest = array();
     //-----------------------------------------
     // NORMAL
     //-----------------------------------------
     if ($this->_outputType == 'normal') {
         //-----------------------------------------
         // Do we have a notification show?
         //-----------------------------------------
         if (!empty($this->memberData['msg_show_notification']) and $this->memberData['_cache']['show_notification_popup']) {
             if (!$this->settings['board_offline'] or $this->memberData['g_access_offline']) {
                 if (strpos(ipsRegistry::$settings['query_string_real'], 'module=messaging') === false) {
                     IPSMember::save($this->memberData['member_id'], array('core' => array('msg_show_notification' => 0)));
                     /* Grab inline notifications... */
                     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications');
                     $notifyLibrary = new $classToLoad($this->registry);
                     $notifyLibrary->setMember($this->memberData);
                     $tmp = $notifyLibrary->getLatestNotificationForInlinePopUp();
                     $weNeed = array('notify_title', 'member_member_id', 'member_PhotoTag', 'member_members_display_name', 'date_parsed', 'title', 'url', 'type', 'content', 'member_HoverCard');
                     foreach ($weNeed as $k) {
                         $notificationLatest[$k] = $tmp[$k];
                     }
                 }
             }
         }
         //-----------------------------------------
         // Add identifier URL
         //-----------------------------------------
         $http = 'http://';
         if (strpos($this->settings['board_url'], 'https://') === 0) {
             $http = 'https://';
         }
         $this->addMetaTag('identifier-url', $http . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
         //-----------------------------------------
         // Add in task image?
         //-----------------------------------------
         $task = '';
         $system_vars_cache['task_next_run'] = isset($system_vars_cache['task_next_run']) ? $system_vars_cache['task_next_run'] : 0;
         if (!$this->settings['task_use_cron'] and time() >= $system_vars_cache['task_next_run'] or defined('FORCE_TASK_KEY')) {
             $_url = !$this->registry->getClass('output')->isHTTPS ? $this->settings['base_url'] : $this->settings['base_url_https'];
             $task = "<div><img src='" . $_url . "app=core&amp;module=task' alt='' style='border: 0px;height:1px;width:1px;' /></div>";
         }
         //-----------------------------------------
         // Grab output
         //-----------------------------------------
         /* Inline msg */
         $inlineMsg = $this->member->sessionClass()->getInlineMessage();
         $templateName = 'globalTemplate';
         $templateGroup = 'global';
         if ($this->useMinimalWrapper) {
             $templateName = 'globalTemplateMinimal';
             $templateGroup = 'global_other';
         }
         /* Do pagination */
         if (strstr($title, '<%pageNumber%>')) {
             $replace = $this->_current_page_title ? ' ' . $this->lang->words['page_title_page'] . ' ' . $this->_current_page_title : '';
             $title = str_replace('<%pageNumber%>', $replace, $title);
         } else {
             if ($this->_current_page_title) {
                 $title = $title . ' ' . $this->lang->words['page_title_page'] . ' ' . $this->_current_page_title;
             }
         }
         $finalOutput = $this->output->getTemplate($templateGroup)->{$templateName}($output, $documentHeadItems, $this->_css, $jsLoaderItems, $this->_metaTags, array('title' => $title, 'applications' => $this->core_fetchApplicationData(), 'page' => $this->_current_page_title, 'notifications' => $notificationLatest ? IPSText::jsonEncodeForTemplate($notificationLatest) : '', 'inlineMsg' => $inlineMsg), array('navigation' => $navigation, 'adHeaderCode' => !empty($extraData['adHeaderCode']) ? $extraData['adHeaderCode'] : '', 'adFooterCode' => !empty($extraData['adFooterCode']) ? $extraData['adFooterCode'] : ''), array('time' => $this->registry->getClass('class_localization')->getDate(time(), 'SHORT', 1), 'mark_read_apps' => IPSLib::getEnabledApplications('itemMarking'), 'lang_chooser' => $this->html_buildLanguageDropDown(), 'skin_chooser' => $this->html_fetchSetsDropDown(), 'copyright' => $this->html_fetchCopyright()), array('ex_time' => (isset($this->request['faster']) and $this->request['faster'] == 'yes') ? $this->_getFasterText() : sprintf("%.4f", IPSDebug::endTimer()), 'gzip_status' => $this->settings['disable_gzip'] == 1 ? $this->lang->words['gzip_off'] : $this->lang->words['gzip_on'], 'server_load' => ipsRegistry::$server_load, 'queries' => $this->DB->getQueryCount(), 'task' => $task));
     } else {
         if ($this->_outputType == 'redirect') {
             $extraData['full'] = 1;
             # SEO?
             if ($extraData['seoTitle']) {
                 $extraData['url'] = $this->output->buildSEOUrl($extraData['url'], 'none', $extraData['seoTitle'], $extraData['seoTemplate']);
             }
             $finalOutput = $this->output->getTemplate('global_other')->redirectTemplate($documentHeadItems, $this->_css, $jsLoaderItems, $extraData['text'], $extraData['url'], $extraData['full']);
         } else {
             if ($this->_outputType == 'popup') {
                 $finalOutput = $this->output->getTemplate('global_other')->displayPopUpWindow($documentHeadItems, $this->_css, $jsLoaderItems, $title, $output);
             }
         }
     }
     //-----------------------------------------
     // Set a class on the body for print
     //-----------------------------------------
     if ($this->_printOnly) {
         $finalOutput = str_replace("<body", "<body class='printpreview'", $finalOutput);
     }
     //-----------------------------------------
     // Return
     //-----------------------------------------
     return $finalOutput;
 }
 /**
  * Wrapper for loginAuthenticate - returns more information
  *
  * @return	mixed		array [0=Words to show, 1=URL to send to, 2=error message language key]
  */
 public function verifyLogin()
 {
     $url = "";
     $member = array();
     $username = '';
     $email = '';
     $password = trim($this->request['ips_password']);
     $errors = '';
     $core = array();
     $mobileSSO = false;
     $memberData = $this->registry->member()->fetchMemberData();
     /* Mobile app + sso */
     if ($memberData['userAgentType'] == 'mobileApp') {
         $file = IPS_ROOT_PATH . 'sources/classes/session/ssoMobileAppLogIn.php';
         if (is_file($file)) {
             require_once $file;
             if (class_exists('ssoMobileAppLogIn')) {
                 $mobileSSO = true;
                 $logIn = new ssoMobileAppLogIn($this->registry);
                 $done = $logIn->authenticate($this->request['ips_username'], $password);
                 $this->return_code = $done['code'];
                 $this->member_data = IPSMember::load(intval($done['memberId']));
                 $member = $this->member_data;
             }
         }
     }
     /* No mobile log in? Log in normally */
     if (!$mobileSSO) {
         //-----------------------------------------
         // Is this a username or email address?
         //-----------------------------------------
         if (IPSText::checkEmailAddress($this->request['ips_username'])) {
             $email = $this->request['ips_username'];
         } else {
             $username = $this->request['ips_username'];
         }
         //-----------------------------------------
         // Check auth
         //-----------------------------------------
         $this->loginAuthenticate($username, $email, $password);
         $member = $this->member_data;
     }
     //-----------------------------------------
     // Check return code...
     //-----------------------------------------
     if ($this->return_code != 'SUCCESS') {
         if ($this->return_code == 'MISSING_DATA') {
             return array(null, null, 'complete_form');
         }
         if ($this->return_code == 'ACCOUNT_LOCKED') {
             $extra = "<!-- -->";
             if ($this->settings['ipb_bruteforce_unlock']) {
                 if ($this->account_unlock) {
                     $time = time() - $this->account_unlock;
                     $time = $this->settings['ipb_bruteforce_period'] - ceil($time / 60) > 0 ? $this->settings['ipb_bruteforce_period'] - ceil($time / 60) : 1;
                 }
             }
             return array(null, null, $this->settings['ipb_bruteforce_unlock'] ? 'bruteforce_account_unlock' : 'bruteforce_account_lock', $time);
         } else {
             if ($this->return_code == 'MISSING_EXTENSIONS') {
                 return array(null, null, 'missing_extensions');
             } else {
                 if ($this->return_code == 'FLAGGED_REMOTE') {
                     return array(null, null, 'flagged_remote');
                 } else {
                     if ($this->return_code == 'VALIDATING') {
                         if ($this->revalidate_url == 'ADMIN_VALIDATION') {
                             return array(null, null, 'validating_remote', ipsRegistry::getClass('class_localization')->words['admin_validation_msg']);
                         } else {
                             return array(null, null, 'validating_remote', "<a href='{$this->revalidate_url}' target='_blank'>" . ipsRegistry::getClass('class_localization')->words['resend_val'] . "</a>");
                         }
                     } else {
                         return array(null, null, 'wrong_auth');
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Is this a partial member?
     // Not completed their sign in?
     //-----------------------------------------
     if ($member['members_created_remote'] and isset($member['full']) and !$member['full']) {
         return array($this->registry->getClass('class_localization')->words['partial_login'], $this->settings['base_url'] . 'app=core&amp;module=global&amp;section=register&amp;do=complete_login&amp;mid=' . $member['member_id'] . '&amp;key=' . $member['timenow']);
     }
     //-----------------------------------------
     // Generate a new log in key
     //-----------------------------------------
     $_ok = 1;
     $_time = $this->settings['login_key_expire'] ? time() + intval($this->settings['login_key_expire']) * 86400 : 0;
     $_sticky = $_time ? 0 : 1;
     $_days = $_time ? $this->settings['login_key_expire'] : 365;
     if (!$member['member_login_key'] or $this->settings['login_key_expire'] and time() > $member['member_login_key_expire']) {
         $member['member_login_key'] = IPSMember::generateAutoLoginKey();
         $core['member_login_key'] = $member['member_login_key'];
         $core['member_login_key_expire'] = $_time;
     }
     //-----------------------------------------
     // Cookie me softly?
     //-----------------------------------------
     if ($this->request['rememberMe']) {
         IPSCookie::set("member_id", $member['member_id'], 1, 0, FALSE, TRUE);
         IPSCookie::set("pass_hash", $member['member_login_key'], $_sticky, $_days, FALSE, TRUE);
         IPSCookie::set("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'), '1', $_sticky, $_days, FALSE, FALSE);
     } else {
         // Ticket 824266
         // IPSCookie::set( "member_id"   , $member['member_id'], 0 );
         // IPSCookie::set( "pass_hash"   , $member['member_login_key'], 0 );
         IPSCookie::set("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'), '1', 0, 0, FALSE, FALSE);
     }
     //-----------------------------------------
     // Remove any COPPA cookies previously set
     //-----------------------------------------
     IPSCookie::set("coppa", '0', 0);
     //-----------------------------------------
     // Update profile if IP addr missing
     //-----------------------------------------
     if ($member['ip_address'] == "" or $member['ip_address'] == '127.0.0.1') {
         $core['ip_address'] = $this->registry->member()->ip_address;
     }
     //-----------------------------------------
     // Create / Update session
     //-----------------------------------------
     $privacy = $member['g_hide_online_list'] || empty($this->settings['disable_anonymous']) && !empty($this->request['anonymous']) ? 1 : 0;
     $session_id = $this->registry->member()->sessionClass()->convertGuestToMember(array('member_name' => $member['members_display_name'], 'member_id' => $member['member_id'], 'member_group' => $member['member_group_id'], 'login_type' => $privacy));
     if (!empty($this->request['referer']) and $this->request['section'] != 'register') {
         if (stripos($this->request['referer'], 'section=register') or stripos($this->request['referer'], 'section=login') or stripos($this->request['referer'], 'section=lostpass') or stripos($this->request['referer'], CP_DIRECTORY . '/')) {
             $url = $this->settings['base_url'];
         } else {
             $url = str_replace('&amp;', '&', $this->request['referer']);
             if ($this->registry->member()->session_type == 'cookie') {
                 $url = preg_replace('#s=(\\w){32}#', "", $url);
             }
         }
     } else {
         $url = $this->settings['base_url'];
     }
     //-----------------------------------------
     // Set our privacy status
     //-----------------------------------------
     $core['login_anonymous'] = intval($privacy) . '&1';
     $core['failed_logins'] = '';
     $core['failed_login_count'] = 0;
     IPSMember::save($member['member_id'], array('core' => $core));
     //-----------------------------------------
     // Clear out any passy change stuff
     //-----------------------------------------
     $this->DB->delete('validating', 'member_id=' . $this->registry->member()->getProperty('member_id') . ' AND lost_pass=1');
     //-----------------------------------------
     // Run member sync
     //-----------------------------------------
     $member['plainPassword'] = $password;
     IPSLib::runMemberSync('onLogin', $member);
     unset($member['plainPassword']);
     //-----------------------------------------
     // Redirect them to either the board
     // index, or where they came from
     //-----------------------------------------
     if (!empty($this->request['return'])) {
         $return = urldecode($this->request['return']);
         if (strpos($return, "http://") === 0 || strpos($return, "https://") === 0) {
             return array($this->registry->getClass('class_localization')->words['partial_login'], $return);
         }
     }
     //-----------------------------------------
     // Still here?
     //-----------------------------------------
     return array($this->registry->getClass('class_localization')->words['partial_login'], $url);
 }
 /**
  * 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']);
 }
Exemple #15
0
 /**
  * Validates a lost password request
  *
  * @return	@e void
  */
 public function lostPasswordValidate()
 {
     /* Check for input and it's in a valid format. */
     $in_user_id = intval(trim(urldecode($this->request['uid'])));
     $in_validate_key = IPSText::md5Clean(trim(urldecode($this->request['aid'])));
     /* Check Input */
     if (!$in_validate_key) {
         $this->registry->output->showError('validation_key_incorrect', 1015);
     }
     if (!preg_match('/^(?:\\d){1,}$/', $in_user_id)) {
         $this->registry->output->showError('uid_key_incorrect', 1016);
     }
     /* Attempt to get the profile of the requesting user */
     $member = IPSMember::load($in_user_id);
     if (!$member['member_id']) {
         $this->registry->output->showError('lostpass_no_member', 1017);
     }
     /* Get validating info.. */
     $validate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id . ' and lost_pass=1'));
     if (!$validate['member_id']) {
         $this->registry->output->showError('lostpass_not_validating', 1018);
     }
     if ($validate['new_reg'] == 1 && $this->settings['reg_auth_type'] == "admin") {
         $this->registry->output->showError('lostpass_new_reg', 4010, true);
     }
     if ($validate['vid'] != $in_validate_key) {
         $this->registry->output->showError('lostpass_key_wrong', 1019);
     } else {
         /* On the same page? */
         if ($validate['lost_pass'] != 1) {
             $this->registry->output->showError('lostpass_not_lostpass', 4011, true);
         }
         /* Send a new random password? */
         if ($this->settings['lp_method'] == 'random') {
             //-----------------------------------------
             // INIT
             //-----------------------------------------
             $save_array = array();
             //-----------------------------------------
             // Generate a new random password
             //-----------------------------------------
             $new_pass = IPSMember::makePassword();
             //-----------------------------------------
             // Generate a new salt
             //-----------------------------------------
             $salt = IPSMember::generatePasswordSalt(5);
             $salt = str_replace('\\', "\\\\", $salt);
             //-----------------------------------------
             // New log in key
             //-----------------------------------------
             $key = IPSMember::generateAutoLoginKey();
             //-----------------------------------------
             // Update...
             //-----------------------------------------
             $save_array['members_pass_salt'] = $salt;
             $save_array['members_pass_hash'] = md5(md5($salt) . md5($new_pass));
             $save_array['member_login_key'] = $key;
             $save_array['member_login_key_expire'] = $this->settings['login_key_expire'] * 60 * 60 * 24;
             $save_array['failed_logins'] = null;
             $save_array['failed_login_count'] = 0;
             //-----------------------------------------
             // Load handler...
             //-----------------------------------------
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
             $this->han_login = new $classToLoad($this->registry);
             $this->han_login->init();
             $this->han_login->changePass($member['email'], md5($new_pass), $new_pass, $member);
             //if ( $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
             //{
             //	$this->registry->output->showError( $this->lang->words['lostpass_external_fail'], 2013 );
             //}
             IPSMember::save($member['member_id'], array('members' => $save_array));
             /* Password has been changed! */
             IPSLib::runMemberSync('onPassChange', $member['member_id'], $new_pass);
             //-----------------------------------------
             // Send out the email...
             //-----------------------------------------
             $message = array('NAME' => $member['members_display_name'], 'THE_LINK' => $this->registry->getClass('output')->buildUrl('app=core&module=usercp&tab=core&area=email', 'publicNoSession'), 'PASSWORD' => $new_pass, 'LOGIN' => $this->registry->getClass('output')->buildUrl('app=core&module=global&section=login', 'publicNoSession'), 'USERNAME' => $member['name'], 'EMAIL' => $member['email'], 'ID' => $member['member_id']);
             IPSText::getTextClass('email')->setPlainTextTemplate(IPSText::getTextClass('email')->getTemplate("lost_pass_email_pass", $member['language']));
             IPSText::getTextClass('email')->buildPlainTextContent($message);
             IPSText::getTextClass('email')->buildHtmlContent($message);
             IPSText::getTextClass('email')->subject = $this->lang->words['lp_random_pass_subject'] . ' ' . $this->settings['board_name'];
             IPSText::getTextClass('email')->to = $member['email'];
             IPSText::getTextClass('email')->sendMail();
             $this->registry->output->setTitle($this->lang->words['activation_form'] . ' - ' . ipsRegistry::$settings['board_name']);
             $this->output = $this->registry->getClass('output')->getTemplate('register')->showLostPassWaitRandom($member);
         } else {
             if ($_POST['pass1'] == "") {
                 $this->registry->output->showError('pass_blank', 10184);
             }
             if ($_POST['pass2'] == "") {
                 $this->registry->output->showError('pass_blank', 10185);
             }
             $pass_a = trim($this->request['pass1']);
             $pass_b = trim($this->request['pass2']);
             /*
             There's no reason for this - http://community.invisionpower.com/resources/bugs.html/_/ip-board/registrations-limit-passwords-to-32-characters-for-no-apparent-reason-r37770
             if( strlen( $pass_a ) < 3 )
             {
             	$this->registry->output->showError( 'pass_too_short', 10186 );						
             }
             */
             if ($pass_a != $pass_b) {
                 $this->registry->output->showError('pass_no_match', 10187);
             }
             $new_pass = md5($pass_a);
             /* Update Member Array */
             $save_array = array();
             /* Generate a new salt */
             $salt = IPSMember::generatePasswordSalt(5);
             $salt = str_replace('\\', "\\\\", $salt);
             /* New log in key */
             $key = IPSMember::generateAutoLoginKey();
             /* Update Array */
             $save_array['members_pass_salt'] = $salt;
             $save_array['members_pass_hash'] = md5(md5($salt) . $new_pass);
             $save_array['member_login_key'] = $key;
             $save_array['member_login_key_expire'] = $this->settings['login_key_expire'] * 60 * 60 * 24;
             $save_array['failed_logins'] = null;
             $save_array['failed_login_count'] = 0;
             /* Change the password */
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
             $this->han_login = new $classToLoad($this->registry);
             $this->han_login->init();
             $this->han_login->changePass($member['email'], $new_pass, $pass_a, $member);
             //-----------------------------------------
             // We'll ignore any remote errors
             //-----------------------------------------
             /*if( $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
                	{
             		// Pass not changed remotely
                	}*/
             /* Update the member */
             IPSMember::save($member['member_id'], array('members' => $save_array));
             /* Password has been changed! */
             IPSLib::runMemberSync('onPassChange', $member['member_id'], $pass_a);
             /* Remove "dead" validation */
             $this->DB->delete('validating', "vid='{$validate['vid']}' OR (member_id={$member['member_id']} AND lost_pass=1)");
             $this->registry->output->silentRedirect($this->registry->getClass('output')->buildUrl('app=core&module=global&section=login&do=autologin&frompass=1'));
         }
     }
 }
 /**
  * Displays the registration form
  *
  * @access	public
  * @param	array 	$form_errors
  * @return	void
  */
 public function registerForm($form_errors = array())
 {
     /* INIT */
     $final_errors = array();
     if ($this->settings['no_reg'] == 1) {
         $this->registry->output->showError('registration_disabled', 10123);
     }
     $coppa = IPSCookie::get('coppa');
     if ($coppa == 'yes') {
         $this->registry->output->showError('awaiting_coppa', 10124);
     }
     $this->settings['username_errormsg'] = str_replace('{chars}', $this->settings['username_characters'], $this->settings['username_errormsg']);
     /* Read T&Cs yet? */
     if (!$this->request['termsread']) {
         if ($this->memberData['member_id']) {
             require_once IPS_ROOT_PATH . 'sources/handlers/han_login.php';
             $this->han_login = new han_login($this->registry);
             $this->han_login->init();
             //-----------------------------------------
             // Set some cookies
             //-----------------------------------------
             IPSCookie::set("member_id", "0");
             IPSCookie::set("pass_hash", "0");
             IPSCookie::set("anonlogin", "-1");
             if (is_array($_COOKIE)) {
                 foreach ($_COOKIE as $cookie => $value) {
                     if (stripos($cookie, $this->settings['cookie_id'] . "ipbforum") !== false) {
                         IPSCookie::set(str_replace($this->settings['cookie_id'], "", $match[0]), '-', -1);
                     }
                 }
             }
             //-----------------------------------------
             // Logout callbacks...
             //-----------------------------------------
             $this->han_login->logoutCallback();
             //-----------------------------------------
             // Do it..
             //-----------------------------------------
             $this->member->sessionClass()->convertMemberToGuest();
             list($privacy, $loggedin) = explode('&', $this->memberData['login_anonymous']);
             IPSMember::save($this->memberData['member_id'], array('core' => array('login_anonymous' => "{$privacy}&0", 'last_activity' => time())));
         }
         /* Continue */
         $cache = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key='reg_rules'"));
         $text = $cache['conf_value'] ? $cache['conf_value'] : $cache['conf_default'];
         /* Load the Parser */
         IPSText::getTextClass('bbcode')->bypass_badwords = 1;
         IPSText::getTextClass('bbcode')->parse_smilies = 1;
         IPSText::getTextClass('bbcode')->parse_html = 1;
         IPSText::getTextClass('bbcode')->parse_bbcode = 1;
         IPSText::getTextClass('bbcode')->parsing_section = 'global';
         $text = IPSText::getTextClass('bbcode')->preDbParse($text);
         $text = IPSText::getTextClass('bbcode')->preDisplayParse($text);
         $this->registry->output->setTitle($this->lang->words['registration_form']);
         $this->registry->output->addNavigation($this->lang->words['registration_form'], '');
         $this->output .= $this->registry->output->getTemplate('register')->registerShowTerms($text, $coppa);
         return;
     } else {
         /* Did we agree to the t&c? */
         if (!$this->request['agree_to_terms']) {
             $this->registry->output->showError('must_agree_to_terms', 10125);
         }
     }
     /* Do we have another URL that one needs to visit to register? */
     $this->DB->build(array('select' => '*', 'from' => 'login_methods', 'where' => 'login_enabled=1'));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         if ($r['login_register_url']) {
             $this->registry->output->silentRedirect($r['login_register_url']);
             exit;
         }
     }
     /* Continue... */
     if ($this->settings['reg_auth_type']) {
         if ($this->settings['reg_auth_type'] == 'admin_user' or $this->settings['reg_auth_type'] == 'user') {
             $this->lang->words['std_text'] .= "<br />" . $this->lang->words['email_validate_text'];
         }
         /* User then admin? */
         if ($this->settings['reg_auth_type'] == 'admin_user') {
             $this->lang->words['std_text'] .= "<br />" . $this->lang->words['user_admin_validation'];
         }
         if ($this->settings['reg_auth_type'] == 'admin') {
             $this->lang->words['std_text'] .= "<br />" . $this->lang->words['just_admin_validation'];
         }
     }
     $captchaHTML = '';
     $qandaHTML = '';
     $this->cache->updateCacheWithoutSaving('_hasStep3', 0);
     /* Q and A Challenge */
     if ($this->settings['registration_qanda']) {
         // Grab a random question...
         $question = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'question_and_answer', 'order' => 'rand()', 'limit' => array(1)));
         if (count($question)) {
             $qandaHTML = $this->registry->output->getTemplate('global_other')->questionAndAnswer($question);
         }
     }
     /* Custom Profile Fields */
     $custom_fields_out = array('required', 'optional');
     require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
     $custom_fields = new customProfileFields();
     $custom_fields->member_data = $member;
     $custom_fields->initData('edit');
     $custom_fields->parseToEdit('register');
     if (count($custom_fields->out_fields)) {
         $this->cache->updateCacheWithoutSaving('_hasStep3', 1);
         foreach ($custom_fields->out_fields as $id => $form_element) {
             if ($custom_fields->cache_data[$id]['pf_not_null'] == 1) {
                 $ftype = 'required';
             } else {
                 $ftype = 'optional';
             }
             $custom_fields_out[$ftype][] = array('name' => $custom_fields->field_names[$id], 'desc' => $custom_fields->field_desc[$id], 'field' => $form_element, 'id' => $id, 'error' => $error, 'type' => $custom_fields->cache_data[$id]['pf_type']);
         }
     }
     /* CAPTCHA */
     if ($this->settings['bot_antispam']) {
         $captchaHTML = $this->registry->getClass('class_captcha')->getTemplate();
     }
     $this->registry->output->setTitle($this->lang->words['registration_form']);
     $this->registry->output->addNavigation($this->lang->words['registration_form'], '');
     /* Other errors */
     $final_errors = array('username' => NULL, 'dname' => NULL, 'password' => NULL, 'email' => NULL);
     foreach (array('username', 'dname', 'password', 'email') as $thing) {
         if (isset($form_errors[$thing]) and is_array($form_errors[$thing]) and count($form_errors[$thing])) {
             $final_errors[$thing] = implode("<br />", $form_errors[$thing]);
         }
     }
     $this->request['UserName'] = $this->request['UserName'] ? $this->request['UserName'] : '';
     $this->request['PassWord'] = $this->request['PassWord'] ? $this->request['PassWord'] : '';
     $this->request['EmailAddress'] = $this->request['EmailAddress'] ? $this->request['EmailAddress'] : '';
     $this->request['EmailAddress_two'] = $this->request['EmailAddress_two'] ? $this->request['EmailAddress_two'] : '';
     $this->request['PassWord_Check'] = $this->request['PassWord_Check'] ? $this->request['PassWord_Check'] : '';
     $this->request['members_display_name'] = $this->request['members_display_name'] ? $this->request['members_display_name'] : '';
     $this->request['time_offset'] = $this->request['time_offset'] ? $this->request['time_offset'] : '';
     $this->request['allow_member_mail'] = $this->request['allow_member_mail'] ? $this->request['allow_member_mail'] : '';
     $this->request['dst'] = $this->request['dst'] ? $this->request['dst'] : '';
     /* Time zone... */
     $this->registry->class_localization->loadLanguageFile(array('public_usercp'), 'core');
     $time_select = array();
     foreach ($this->lang->words as $k => $v) {
         if (strpos($k, "time_") === 0) {
             $k = str_replace("time_", '', $k);
             if (preg_match("/^[\\-\\d\\.]+\$/", $k)) {
                 $time_select[$k] = $v;
             }
         }
     }
     ksort($time_select);
     /* set default.. */
     $this->request['time_offset'] = $this->request['time_offset'] ? $this->request['time_offset'] : $this->settings['time_offset'];
     /* Need username? */
     $uses_name = false;
     foreach ($this->cache->getCache('login_methods') as $method) {
         if ($method['login_user_id'] == 'username') {
             $uses_name = true;
         }
     }
     /* Get form HTML */
     $this->output .= $this->registry->output->getTemplate('register')->registerForm($form_errors['general'], array('TEXT' => $this->lang->words['std_text'], 'coppa_user' => $coppa, 'captchaHTML' => $captchaHTML, 'qandaHTML' => $qandaHTML, 'requireName' => $uses_name), $final_errors, $time_select, $custom_fields_out);
     /* Run the member sync module */
     IPSLib::runMemberSync('onRegisterForm');
 }
Exemple #17
0
         $set[] = "email='{$email}'";
         if (substr($GLOBALS["FORUMLINK"], 0, 3) == "smf") {
             do_sqlquery("UPDATE `{$db_prefix}members` SET `email" . ($GLOBALS["FORUMLINK"] == "smf" ? "A" : "_a") . "ddress`='" . $email . "' WHERE " . ($GLOBALS["FORUMLINK"] == "smf" ? "`ID_MEMBER`" : "`id_member`") . "=" . $CURUSER["smf_fid"]);
         } elseif ($GLOBALS["FORUMLINK"] == "ipb") {
             if (!defined('IPS_ENFORCE_ACCESS')) {
                 define('IPS_ENFORCE_ACCESS', true);
             }
             if (!defined('IPB_THIS_SCRIPT')) {
                 define('IPB_THIS_SCRIPT', 'public');
             }
             require_once $THIS_BASEPATH . '/ipb/initdata.php';
             require_once IPS_ROOT_PATH . 'sources/base/ipsRegistry.php';
             require_once IPS_ROOT_PATH . 'sources/base/ipsController.php';
             $registry = ipsRegistry::instance();
             $registry->init();
             IPSMember::save($CURUSER["ipb_fid"], array("members" => array("email" => "{$email}")));
         }
     }
 }
 // <--- Reverify Mail Hack by Petr1fied - End
 //Profile Status by Yupy Start
 if (isset($_POST['status']) && ($status = $_POST['status']) && !empty($status)) {
     do_sqlquery("INSERT INTO {$TABLE_PREFIX}profile_status (userid, last_status, last_update) VALUES (" . sqlesc($CURUSER['uid']) . ", " . sqlesc($status) . ", " . time() . ") ON DUPLICATE KEY UPDATE last_status = values(last_status), last_update = values(last_update)") or sqlerr(__FILE__, __LINE__);
 }
 //Profile Status by Yupy End
 if ($idlangue > 0) {
     $set[] = "language={$idlangue}";
 }
 if ($idstyle > 0) {
     $set[] = "style={$idstyle}";
 }
Exemple #18
0
 /**
  * Check for mod posts or restricted posts or ignored
  *
  * @param	array	[Array of author data, uses getAuthor if none]
  * @param	array	[Array of status owner information uses $this->_internalData['StatusOwner'] if none]
  * @return	bool
  */
 protected function _okToPost($author = null, $owner = null)
 {
     $author = $author === null ? $this->getAuthor() : $author;
     $owner = $owner === null ? $this->_internalData['StatusOwner'] : $owner;
     /* Restricted Posting */
     if ($author['restrict_post']) {
         if ($author['restrict_post'] == 1) {
             return FALSE;
         }
         $post_arr = IPSMember::processBanEntry($author['restrict_post']);
         if (time() >= $post_arr['date_end']) {
             /* Update this member's profile */
             IPSMember::save($author['member_id'], array('core' => array('restrict_post' => 0)));
         } else {
             return FALSE;
         }
     }
     /* Moderated Posting */
     if ($author['mod_posts']) {
         if ($author['mod_posts'] == 1) {
             return FALSE;
         } else {
             $mod_arr = IPSMember::processBanEntry($author['mod_posts']);
             if (time() >= $mod_arr['date_end']) {
                 /* Update this member's profile */
                 IPSMember::save($author['member_id'], array('core' => array('mod_posts' => 0)));
             } else {
                 return FALSE;
             }
         }
     }
     /* Member is ignoring you! */
     if (IPSMember::checkIgnoredStatus($author['member_id'], $owner['member_id'], 'messages')) {
         return false;
     }
     return TRUE;
 }
Exemple #19
0
 /**
  * Merge two members
  *
  * @return	@e void	[Redirects to member account]
  * @author	Brandon Farber
  */
 protected function _completeMerge()
 {
     if (!$this->request['confirm']) {
         $member = IPSMember::load($this->request['member_id']);
         //-----------------------------------------
         // Load member
         //-----------------------------------------
         $newMember = NULL;
         $_newMember = NULL;
         /* Name */
         if ($this->request['name']) {
             $newMember = IPSMember::load($this->request['name'], '', 'displayname');
             $_newMember = $newMember['member_id'];
         }
         /* Email */
         if ($this->request['email']) {
             $newMember = IPSMember::load($this->request['email'], '', 'email');
             if ($_newMember !== NULL and $_newMember != $newMember['member_id']) {
                 $this->registry->output->global_error = $this->lang->words['err_transfer_badmulti'];
                 $this->_mergeForm();
                 return false;
             }
             $_newMember = $newMember['member_id'];
         }
         /* ID */
         if ($this->request['target_id']) {
             $newMember = IPSMember::load(intval($this->request['target_id']), '', 'id');
             if ($_newMember !== NULL and $_newMember != $newMember['member_id']) {
                 $this->registry->output->global_error = $this->lang->words['err_transfer_badmulti'];
                 $this->_mergeForm();
                 return false;
             }
             $_newMember = $newMember['member_id'];
         }
         if (!$newMember['member_id']) {
             $this->registry->output->global_error = $this->lang->words['no_merge_id'];
             $this->_mergeForm();
             return false;
         }
         $member2 = $newMember;
         if (!$member['member_id'] or !$member2['member_id']) {
             $this->registry->output->global_error = $this->lang->words['no_merge_id'];
             $this->_mergeForm();
             return false;
         }
         //-----------------------------------------
         // Output
         //-----------------------------------------
         $this->registry->output->html .= $this->html->mergeConfirm($member, $newMember);
     } else {
         $member = IPSMember::load($this->request['member_id']);
         $member2 = IPSMember::load($this->request['member_id2']);
         if (!$member['member_id'] or !$member2['member_id']) {
             $this->registry->output->global_error = $this->lang->words['no_merge_id'];
             $this->_mergeForm();
             return false;
         }
         //-----------------------------------------
         // Take care of forum stuff
         //-----------------------------------------
         $this->DB->update('posts', array('author_name' => $member['members_display_name'], 'author_id' => $member['member_id']), "author_id=" . $member2['member_id']);
         $this->DB->update('topics', array('starter_name' => $member['members_display_name'], 'seo_first_name' => $member['members_seo_name'], 'starter_id' => $member['member_id']), "starter_id=" . $member2['member_id']);
         $this->DB->update('topics', array('last_poster_name' => $member['members_display_name'], 'seo_last_name' => $member['members_seo_name'], 'last_poster_id' => $member['member_id']), "last_poster_id=" . $member2['member_id']);
         $this->DB->update('announcements', array('announce_member_id' => $member['member_id']), "announce_member_id=" . $member2['member_id']);
         $this->DB->update('attachments', array('attach_member_id' => $member['member_id']), "attach_member_id=" . $member2['member_id']);
         $this->DB->update('polls', array('starter_id' => $member['member_id']), "starter_id=" . $member2['member_id']);
         $this->DB->update('topic_ratings', array('rating_member_id' => $member['member_id']), "rating_member_id=" . $member2['member_id']);
         $this->DB->update('moderators', array('member_id' => $member['member_id']), "member_id=" . $member2['member_id']);
         $this->DB->update('forums', array('last_poster_name' => $member['members_display_name'], 'seo_last_name' => $member['members_seo_name'], 'last_poster_id' => $member['member_id']), "last_poster_id=" . $member2['member_id']);
         $this->DB->update('core_share_links_log', array('log_member_id' => $member['member_id']), "log_member_id=" . $member2['member_id']);
         $this->DB->update('core_soft_delete_log', array('sdl_obj_member_id' => $member['member_id']), "sdl_obj_member_id=" . $member2['member_id']);
         $this->DB->update('rss_import', array('rss_import_mid' => $member['member_id']), "rss_import_mid=" . $member2['member_id']);
         $this->DB->update('core_tags', array('tag_member_id' => $member['member_id']), "tag_member_id=" . $member2['member_id']);
         /* Update archived posts */
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/archive/writer.php', 'classes_archive_writer');
         $archiveWriter = new $classToLoad();
         $archiveWriter->setApp('forums');
         $archiveWriter->update(array('archive_author_id' => $member['member_id'], 'archive_author_name' => $member['members_display_name']), 'archive_author_id=' . $member2['member_id']);
         //-----------------------------------------
         // Clean up profile stuff
         //-----------------------------------------
         $this->DB->update('profile_portal_views', array('views_member_id' => $member['member_id']), "views_member_id=" . $member2['member_id']);
         $this->DB->update('members_warn_logs', array('wl_member' => $member['member_id']), "wl_member=" . $member2['member_id']);
         $this->DB->update('members_warn_logs', array('wl_moderator' => $member['member_id']), "wl_moderator=" . $member2['member_id']);
         $this->DB->update('dnames_change', array('dname_member_id' => $member['member_id']), "dname_member_id=" . $member2['member_id']);
         $this->DB->update('mobile_notifications', array('member_id' => $member['member_id']), "member_id=" . $member2['member_id']);
         $this->DB->update('inline_notifications', array('notify_to_id' => $member['member_id']), "notify_to_id=" . $member2['member_id']);
         $this->DB->update('inline_notifications', array('notify_from_id' => $member['member_id']), "notify_from_id=" . $member2['member_id']);
         //-----------------------------------------
         // Statuses
         //-----------------------------------------
         $this->DB->update('member_status_actions', array('action_member_id' => $member['member_id']), "action_member_id=" . $member2['member_id']);
         $this->DB->update('member_status_actions', array('action_status_owner' => $member['member_id']), "action_status_owner=" . $member2['member_id']);
         $this->DB->update('member_status_replies', array('reply_member_id' => $member['member_id']), "reply_member_id=" . $member2['member_id']);
         $this->DB->update('member_status_updates', array('status_member_id' => $member['member_id']), "status_member_id=" . $member2['member_id']);
         $this->DB->update('member_status_updates', array('status_author_id' => $member['member_id']), "status_author_id=" . $member2['member_id']);
         $statusUpdates = array();
         $this->DB->build(array('select' => 'status_id', 'from' => 'member_status_updates', 'where' => 'status_member_id=' . $member['member_id']));
         $res = $this->DB->execute();
         while ($r = $this->DB->fetch($res)) {
             $this->registry->getClass('memberStatus')->rebuildStatus($r);
         }
         //-----------------------------------------
         // Update admin stuff
         //-----------------------------------------
         $this->DB->update('upgrade_history', array('upgrade_mid' => $member['member_id']), "upgrade_mid=" . $member2['member_id']);
         $this->DB->update('admin_logs', array('member_id' => $member['member_id']), "member_id=" . $member2['member_id']);
         $this->DB->update('error_logs', array('log_member' => $member['member_id']), "log_member=" . $member2['member_id']);
         $this->DB->update('moderator_logs', array('member_id' => $member['member_id']), "member_id=" . $member2['member_id']);
         $this->DB->update('rc_comments', array('comment_by' => $member['member_id']), "comment_by=" . $member2['member_id']);
         $this->DB->update('rc_reports', array('report_by' => $member['member_id']), "report_by=" . $member2['member_id']);
         $this->DB->update('rc_reports_index', array('updated_by' => $member['member_id']), "updated_by=" . $member2['member_id']);
         $this->DB->update('rc_reports_index', array('exdat1' => $member['member_id']), "seotemplate='showuser' AND exdat1=" . $member2['member_id']);
         $this->DB->update('reputation_cache', array('type_id' => $member['member_id']), "type='member' AND type_id=" . $member2['member_id']);
         $this->DB->update('reputation_index', array('member_id' => $member['member_id']), "member_id=" . $member2['member_id']);
         //-----------------------------------------
         // Fix up member messages...
         //-----------------------------------------
         $this->DB->update('message_posts', array('msg_author_id' => $member['member_id']), 'msg_author_id=' . $member2['member_id']);
         $this->DB->update('message_topics', array('mt_starter_id' => $member['member_id']), 'mt_starter_id=' . $member2['member_id']);
         $this->DB->update('message_topics', array('mt_to_member_id' => $member['member_id']), 'mt_to_member_id=' . $member2['member_id']);
         //-----------------------------------------
         // Stuff that can't have duplicates
         //-----------------------------------------
         //-----------------------------------------
         // Likes - also invalidates likes cache
         //-----------------------------------------
         /* Followed stuffs */
         require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php';
         /*noLibHook*/
         $like = classes_like::bootstrap('core', 'default');
         $like->updateMemberId($member2['member_id'], $member['member_id']);
         //-----------------------------------------
         // Poll votes
         //-----------------------------------------
         $voters = array();
         $this->DB->build(array('select' => 'tid', 'from' => 'voters', 'where' => 'member_id=' . $member['member_id']));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             $voters[] = $r['tid'];
         }
         if (count($voters)) {
             $this->DB->update('voters', array('member_id' => $member['member_id']), "member_id=" . $member2['member_id'] . " AND tid NOT IN(" . implode(',', $voters) . ")");
         } else {
             $this->DB->update('voters', array('member_id' => $member['member_id']), "member_id=" . $member2['member_id']);
         }
         //-----------------------------------------
         // Profile ratings
         //-----------------------------------------
         $ratingsFor = array();
         $ratingsGot = array();
         $this->DB->build(array('select' => 'rating_by_member_id,rating_for_member_id', 'from' => 'profile_ratings', 'where' => 'rating_by_member_id=' . $member['member_id'] . ' OR rating_for_member_id=' . $member['member_id']));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             if ($r['rating_by_member_id'] == $member['member_id']) {
                 $ratingsFor[] = $r['rating_for_member_id'];
             }
             if ($r['rating_for_member_id'] == $member['member_id']) {
                 $ratingsGot[] = $r['rating_by_member_id'];
             }
         }
         if (count($ratingsFor)) {
             $this->DB->update('profile_ratings', array('rating_by_member_id' => $member['member_id']), "rating_by_member_id=" . $member2['member_id'] . " AND rating_for_member_id NOT IN(" . implode(',', $ratingsFor) . ")");
         } else {
             $this->DB->update('profile_ratings', array('rating_by_member_id' => $member['member_id']), "rating_by_member_id=" . $member2['member_id']);
         }
         if (count($ratingsGot)) {
             $this->DB->update('profile_ratings', array('rating_for_member_id' => $member['member_id']), "rating_for_member_id=" . $member2['member_id'] . " AND rating_by_member_id NOT IN(" . implode(',', $ratingsGot) . ")");
         } else {
             $this->DB->update('profile_ratings', array('rating_for_member_id' => $member['member_id']), "rating_for_member_id=" . $member2['member_id']);
         }
         //-----------------------------------------
         // Profile friends
         //-----------------------------------------
         $myFriends = array();
         $friendsMy = array();
         $this->DB->build(array('select' => 'friends_member_id,friends_friend_id', 'from' => 'profile_friends', 'where' => 'friends_member_id=' . $member['member_id'] . ' OR friends_friend_id=' . $member['member_id']));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             if ($r['friends_member_id'] == $member['member_id']) {
                 $myFriends[] = $r['friends_friend_id'];
             }
             if ($r['friends_friend_id'] == $member['member_id']) {
                 $friendsMy[] = $r['friends_member_id'];
             }
         }
         if (count($myFriends)) {
             $this->DB->update('profile_friends', array('friends_member_id' => $member['member_id']), "friends_member_id=" . $member2['member_id'] . " AND friends_friend_id NOT IN(" . implode(',', $myFriends) . ")");
         } else {
             $this->DB->update('profile_friends', array('friends_member_id' => $member['member_id']), "friends_member_id=" . $member2['member_id']);
         }
         if (count($friendsMy)) {
             $this->DB->update('profile_friends', array('friends_friend_id' => $member['member_id']), "friends_friend_id=" . $member2['member_id'] . " AND friends_member_id NOT IN(" . implode(',', $friendsMy) . ")");
         } else {
             $this->DB->update('profile_friends', array('friends_friend_id' => $member['member_id']), "friends_friend_id=" . $member2['member_id']);
         }
         //-----------------------------------------
         // Ignored users
         //-----------------------------------------
         $myIgnored = array();
         $ignoredMe = array();
         $this->DB->build(array('select' => 'ignore_owner_id,ignore_ignore_id', 'from' => 'ignored_users', 'where' => 'ignore_owner_id=' . $member['member_id'] . ' OR ignore_ignore_id=' . $member['member_id']));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             if ($r['ignore_owner_id'] == $member['member_id']) {
                 $myIgnored[] = $r['ignore_ignore_id'];
             }
             if ($r['ignore_ignore_id'] == $member['member_id']) {
                 $ignoredMe[] = $r['ignore_owner_id'];
             }
         }
         if (count($myIgnored)) {
             $this->DB->update('ignored_users', array('ignore_owner_id' => $member['member_id']), "ignore_owner_id=" . $member2['member_id'] . " AND ignore_ignore_id NOT IN(" . implode(',', $myIgnored) . ")");
         } else {
             $this->DB->update('ignored_users', array('ignore_owner_id' => $member['member_id']), "ignore_owner_id=" . $member2['member_id']);
         }
         if (count($ignoredMe)) {
             $this->DB->update('ignored_users', array('ignore_ignore_id' => $member['member_id']), "ignore_ignore_id=" . $member2['member_id'] . " AND ignore_owner_id NOT IN(" . implode(',', $ignoredMe) . ")");
         } else {
             $this->DB->update('ignored_users', array('ignore_ignore_id' => $member['member_id']), "ignore_ignore_id=" . $member2['member_id']);
         }
         //-----------------------------------------
         // Message topic mapping
         //-----------------------------------------
         $pms = array();
         $this->DB->build(array('select' => 'map_topic_id', 'from' => 'message_topic_user_map', 'where' => 'map_user_id=' . $member['member_id']));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             $pms[] = $r['map_topic_id'];
         }
         if (count($pms)) {
             $this->DB->update('message_topic_user_map', array('map_user_id' => $member['member_id']), "map_user_id=" . $member2['member_id'] . " AND map_topic_id NOT IN(" . implode(',', $pms) . ")");
         } else {
             $this->DB->update('message_topic_user_map', array('map_user_id' => $member['member_id']), 'map_user_id=' . $member2['member_id']);
         }
         //-----------------------------------------
         // Admin permissions
         //-----------------------------------------
         $count = $this->DB->buildAndFetch(array('select' => 'row_id', 'from' => 'admin_permission_rows', 'where' => "row_id_type='member' AND row_id=" . $member['member_id']));
         if (!$count['row_id']) {
             $this->DB->update('admin_permission_rows', array('row_id' => $member['member_id']), "row_id_type='member' AND row_id=" . $member2['member_id']);
         }
         //-----------------------------------------
         // Member Sync
         //-----------------------------------------
         try {
             IPSMember::save($member['member_id'], array('core' => array('posts' => $member['posts'] + $member2['posts'], 'warn_level' => $member['warn_level'] + $member2['warn_level'], 'warn_lastwarn' => $member2['warn_lastwarn'] > $member['warn_lastwarn'] ? $member2['warn_lastwarn'] : $member['warn_lastwarn'], 'last_post' => $member2['last_post'] > $member['last_post'] ? intval($member2['last_post']) : intval($member['last_post']), 'last_visit' => $member2['last_visit'] > $member['last_visit'] ? $member2['last_visit'] : $member['last_visit']), 'extendedProfile' => array('pp_reputation_points' => $member['pp_reputation_points'] + $member2['pp_reputation_points'])));
         } catch (Exception $error) {
             $this->registry->output->showError($error->getMessage(), 11247);
         }
         IPSLib::runMemberSync('onMerge', $member, $member2);
         //-----------------------------------------
         // Delete member 2
         //-----------------------------------------
         IPSMember::remove($member2['member_id'], false);
         //-----------------------------------------
         // Get current stats...
         //-----------------------------------------
         $this->cache->rebuildCache('stats', 'global');
         $this->cache->rebuildCache('moderators', 'forums');
         $this->cache->rebuildCache('announcements', 'forums');
         //-----------------------------------------
         // Admin logs
         //-----------------------------------------
         $this->registry->adminFunctions->saveAdminLog(sprintf($this->lang->words['merged_accounts_log'], $member2['members_display_name'], $member['members_display_name']));
         //-----------------------------------------
         // Redirect
         //-----------------------------------------
         $this->registry->output->global_message = $this->lang->words['merged_members'];
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . "module=members&amp;section=members&amp;do=viewmember&amp;member_id=" . $member['member_id']);
     }
 }
 /**
  * Adds a new profile comment to the database
  *
  * @access	public
  * @param	integer	$comment_for_id	Member id that this comment is for
  * @param	string	$comment		Text of the comment to create
  * @return	string					Error key on failure, blank on success
  */
 public function addCommentToDB($comment_for_id, $comment)
 {
     /* Load the member that this comment is for */
     $member = IPSMember::load($comment_for_id);
     /* Make sure we found a member */
     if (!$member['member_id']) {
         return 'error';
     }
     /* Are we allowed to comment? */
     if (!$this->memberData['g_reply_other_topics']) {
         return 'nopermission';
     }
     if ($this->memberData['restrict_post']) {
         if ($this->memberData['restrict_post'] == 1) {
             return 'nopermission';
         }
         $post_arr = IPSMember::processBanEntry($this->memberData['restrict_post']);
         if (time() >= $post_arr['date_end']) {
             /* Update this member's profile */
             IPSMember::save($this->memberData['member_id'], array('core' => array('restrict_post' => 0)));
         } else {
             return 'nopermission';
         }
     }
     /* Does this member have mod_posts enabled? */
     $comment_approved = 1;
     if ($this->memberData['mod_posts']) {
         if ($this->memberData['mod_posts'] == 1) {
             $comment_approved = 0;
         } else {
             $mod_arr = IPSMember::processBanEntry($this->memberData['mod_posts']);
             if (time() >= $mod_arr['date_end']) {
                 /* Update this member's profile */
                 IPSMember::save($this->memberData['member_id'], array('core' => array('mod_posts' => 0)));
             } else {
                 $comment_approved = 0;
             }
         }
     }
     /* Format the comment */
     $comment = IPSText::truncate($comment, 400);
     $comment = preg_replace("#(\r\n|\r|\n|<br />|<br>){1,}#s", "\n", $comment);
     $comment = trim(IPSText::getTextClass('bbcode')->stripBadWords($comment));
     /* Make sure we still have a comment */
     if (!$comment) {
         return 'error-no-comment';
     }
     /* Comment requires approval? */
     if ($member['pp_setting_moderate_comments'] and $member['member_id'] != $this->memberData['member_id']) {
         $comment_approved = 0;
     }
     /* Member is ignoring you! */
     if ($comment_approved) {
         $_you_are_being_ignored = explode(",", $member['ignored_users']);
         if (is_array($_you_are_being_ignored) and count($_you_are_being_ignored)) {
             if (in_array($this->memberData['member_id'], $_you_are_being_ignored)) {
                 $comment_approved = 0;
             }
         }
     }
     /* Add comment to the DB... */
     $this->DB->insert('profile_comments', array('comment_for_member_id' => $comment_for_id, 'comment_by_member_id' => $this->memberData['member_id'], 'comment_date' => time(), 'comment_ip_address' => $this->member->ip_address, 'comment_approved' => $comment_approved, 'comment_content' => nl2br($comment)));
     $new_id = $this->DB->getInsertId();
     /* Send notifications.. */
     if (!$comment_approved and $member['pp_setting_notify_comments'] and $member['member_id'] != $this->memberData['member_id']) {
         IPSText::getTextClass('email')->getTemplate("new_comment_request", $member['language']);
         IPSText::getTextClass('email')->buildMessage(array('MEMBERS_DISPLAY_NAME' => $member['members_display_name'], 'COMMENT_NAME' => $this->memberData['members_display_name'], 'LINK' => $this->settings['board_url'] . '/index.' . $this->settings['php_ext'] . '?showuser='******'member_id']));
         $message = IPSText::getTextClass('email')->message;
         $subject = IPSText::getTextClass('email')->subject;
         $to = $member;
         $from = $this->memberData;
         $return_msg = 'pp_comment_added_mod';
     } else {
         if ($member['pp_setting_notify_comments'] and $member['member_id'] != $this->memberData['member_id']) {
             IPSText::getTextClass('email')->getTemplate("new_comment_added", $member['language']);
             IPSText::getTextClass('email')->buildMessage(array('MEMBERS_DISPLAY_NAME' => $member['members_display_name'], 'COMMENT_NAME' => $this->memberData['members_display_name'], 'LINK' => $this->settings['board_url'] . '/index.' . $this->settings['php_ext'] . '?showuser='******'member_id']));
             $message = IPSText::getTextClass('email')->message;
             $subject = IPSText::getTextClass('email')->subject;
             $to = $member;
             $from = $this->memberData;
             $return_msg = '';
         }
     }
     /* Got anything to send? */
     if ($message and $subject) {
         /* Email ? */
         if ($member['pp_setting_notify_comments'] == 'email' or $member['pp_setting_notify_comments'] and $member['members_disable_pm']) {
             IPSText::getTextClass('email')->subject = $subject;
             IPSText::getTextClass('email')->message = $message;
             IPSText::getTextClass('email')->to = $to['email'];
             IPSText::getTextClass('email')->sendMail();
         } else {
             if ($member['pp_setting_notify_comments'] != 'none') {
                 require_once IPSLib::getAppDir('members') . '/sources/classes/messaging/messengerFunctions.php';
                 $this->messengerFunctions = new messengerFunctions($this->registry);
                 try {
                     $this->messengerFunctions->sendNewPersonalTopic($to['member_id'], $from['member_id'], array(), $subject, IPSText::getTextClass('editor')->method == 'rte' ? nl2br($message) : $message, array('origMsgID' => 0, 'fromMsgID' => 0, 'postKey' => md5(microtime()), 'trackMsg' => 0, 'addToSentFolder' => 0, 'hideCCUser' => 0, 'forcePm' => 1, 'isSystem' => 1));
                 } catch (Exception $error) {
                     $msg = $error->getMessage();
                     $toMember = IPSMember::load($toMemberID, 'core', 'displayname');
                     if (strstr($msg, 'BBCODE_')) {
                         $msg = str_replace('BBCODE_', $msg, 10258);
                         $this->registry->output->showError($msg);
                     } else {
                         if (isset($this->lang->words['err_' . $msg])) {
                             $this->lang->words['err_' . $msg] = $this->lang->words['err_' . $msg];
                             $this->lang->words['err_' . $msg] = str_replace('#NAMES#', implode(",", $this->messengerFunctions->exceptionData), $this->lang->words['err_' . $msg]);
                             $this->lang->words['err_' . $msg] = str_replace('#TONAME#', $toMember['members_display_name'], $this->lang->words['err_' . $msg]);
                             $this->lang->words['err_' . $msg] = str_replace('#FROMNAME#', $this->memberData['members_display_name'], $this->lang->words['err_' . $msg]);
                             $this->registry->output->showError('err_' . $msg, 10259);
                         } else {
                             $_msgString = $this->lang->words['err_UNKNOWN'] . ' ' . $msg;
                             $this->registry->output->showError('err_UNKNOWN', 10260);
                         }
                     }
                 }
             }
         }
     }
     return $return_msg;
 }
Exemple #21
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;
 }
 /**
  * Validation completion.  This is the action hit when a user clicks a validation link from their email for
  * lost password, email change and new registration.
  *
  * @return	@e void
  */
 protected function _autoValidate()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $in_user_id = intval(trim(urldecode($this->request['uid'])));
     $in_validate_key = substr(IPSText::alphanumericalClean(urldecode($this->request['aid'])), 0, 32);
     $in_type = trim($this->request['type']);
     $in_type = $in_type ? $in_type : 'reg';
     //-----------------------------------------
     // Attempt to get the profile of the requesting user
     //-----------------------------------------
     $member = IPSMember::load($in_user_id, 'members');
     if (!$member['member_id']) {
         $this->_showManualForm($in_type, 'reg_error_validate');
         return;
     }
     //-----------------------------------------
     // Get validating info..
     //-----------------------------------------
     if ($in_type == 'lostpass') {
         $validate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id . " AND lost_pass=1"));
     } else {
         if ($in_type == 'newemail') {
             $validate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id . " AND email_chg=1"));
         } else {
             $validate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id));
         }
     }
     //-----------------------------------------
     // Checks...
     //-----------------------------------------
     if (!$validate['member_id']) {
         $this->registry->output->showError('no_validate_key', 10120);
     }
     //-----------------------------------------
     // Changed to check if this is an admin flagged
     //	account for a spam user too
     //-----------------------------------------
     if ($validate['new_reg'] == 1 && ($this->settings['reg_auth_type'] == "admin" || $validate['spam_flag'])) {
         $this->registry->output->showError('validate_admin_turn', 10121);
     }
     if ($validate['vid'] != $in_validate_key) {
         $this->registry->output->showError('validation_key_invalid', 10122);
     }
     //-----------------------------------------
     // Captcha (from posted form, not GET)
     //-----------------------------------------
     if ($this->settings['use_captcha'] and $this->request['uid']) {
         if ($this->registry->getClass('class_captcha')->validate($this->request['captcha_unique_id'], $this->request['captcha_input']) !== TRUE) {
             $this->_showManualForm($in_type, 'reg_error_anti_spam');
             return;
         }
     }
     //-----------------------------------------
     // REGISTER VALIDATE
     //-----------------------------------------
     if ($validate['new_reg'] == 1) {
         if ($member['member_group_id'] == $this->settings['auth_group']) {
             if (!$validate['real_group']) {
                 $validate['real_group'] = $this->settings['member_group'];
             } else {
                 if (!isset($this->caches['group_cache'][$validate['real_group']])) {
                     $validate['real_group'] = $this->settings['member_group'];
                 }
             }
         }
         //-----------------------------------------
         // SELF-VERIFICATION...
         // 12.14.2009 Changed from != 'admin_user' to
         //	be more inclusive (just self-verification only)
         //-----------------------------------------
         if ($this->settings['reg_auth_type'] == 'user') {
             if ($member['member_group_id'] == $this->settings['auth_group']) {
                 IPSMember::save($member['member_id'], array('members' => array('member_group_id' => $validate['real_group'])));
             }
             /* Reset newest member */
             $stat_cache = $this->caches['stats'];
             if ($member['members_display_name'] and $member['member_id'] and !$this->caches['group_cache'][$validate['real_group']]['g_hide_online_list']) {
                 $stat_cache['last_mem_name'] = $member['members_display_name'];
                 $stat_cache['last_mem_name_seo'] = IPSText::makeSeoTitle($member['members_display_name']);
                 $stat_cache['last_mem_id'] = $member['member_id'];
             }
             $stat_cache['mem_count'] += 1;
             $this->cache->setCache('stats', $stat_cache, array('array' => 1));
             //-----------------------------------------
             // Remove "dead" validation
             //-----------------------------------------
             $this->DB->delete('validating', "vid='" . $validate['vid'] . "'");
             IPSLib::runMemberSync('onCompleteAccount', $member);
             $this->registry->output->silentRedirect($this->settings['base_url'] . '&app=core&module=global&section=login&do=autologin&fromreg=1');
         } else {
             //-----------------------------------------
             // Update DB row...
             //-----------------------------------------
             $this->DB->update('validating', array('user_verified' => 1), 'vid=\'' . $validate['vid'] . '\'');
             //-----------------------------------------
             // Print message
             //-----------------------------------------
             $this->registry->output->setTitle($this->lang->words['validation_complete'] . ' - ' . ipsRegistry::$settings['board_name']);
             $this->output = $this->registry->getClass('output')->getTemplate('register')->showPreview($member);
         }
     } else {
         if ($validate['lost_pass'] == 1) {
             //-----------------------------------------
             // INIT
             //-----------------------------------------
             $save_array = array();
             //-----------------------------------------
             // Generate a new random password
             //-----------------------------------------
             $new_pass = IPSMember::makePassword();
             //-----------------------------------------
             // Generate a new salt
             //-----------------------------------------
             $salt = IPSMember::generatePasswordSalt(5);
             $salt = str_replace('\\', "\\\\", $salt);
             //-----------------------------------------
             // New log in key
             //-----------------------------------------
             $key = IPSMember::generateAutoLoginKey();
             //-----------------------------------------
             // Update...
             //-----------------------------------------
             $save_array['members_pass_salt'] = $salt;
             $save_array['members_pass_hash'] = md5(md5($salt) . md5($new_pass));
             $save_array['member_login_key'] = $key;
             $save_array['member_login_key_expire'] = $this->settings['login_key_expire'] * 60 * 60 * 24;
             //-----------------------------------------
             // Load handler...
             //-----------------------------------------
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
             $this->han_login = new $classToLoad($this->registry);
             $this->han_login->init();
             $this->han_login->changePass($member['email'], md5($new_pass), $new_pass, $member);
             if ($this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'SUCCESS') {
                 $this->registry->output->showError('lostpass_external_fail', 2015, true);
             }
             IPSMember::save($member['member_id'], array('members' => $save_array));
             //-----------------------------------------
             // Send out the email...
             //-----------------------------------------
             IPSText::getTextClass('email')->getTemplate("lost_pass_email_pass", $member['language']);
             IPSText::getTextClass('email')->buildMessage(array('NAME' => $member['members_display_name'], 'THE_LINK' => $this->registry->getClass('output')->buildSEOUrl('app=core&module=usercp&tab=core&area=email', 'publicNoSession', 'false'), 'PASSWORD' => $new_pass, 'LOGIN' => $this->registry->getClass('output')->buildSEOUrl('app=core&module=global&section=login', 'publicNoSession', 'false'), 'USERNAME' => $member['name'], 'EMAIL' => $member['email'], 'ID' => $member['member_id']));
             IPSText::getTextClass('email')->subject = $this->lang->words['lp_random_pass_subject'] . ' ' . $this->settings['board_name'];
             IPSText::getTextClass('email')->to = $member['email'];
             IPSText::getTextClass('email')->sendMail();
             $this->registry->output->setTitle($this->lang->words['validation_complete'] . ' - ' . ipsRegistry::$settings['board_name']);
             //-----------------------------------------
             // Remove "dead" validation
             //-----------------------------------------
             $this->DB->delete('validating', "vid='" . $validate['vid'] . "' OR (member_id={$member['member_id']} AND lost_pass=1)");
             $this->output = $this->registry->getClass('output')->getTemplate('register')->showLostPassWaitRandom($member);
         } else {
             if ($validate['email_chg'] == 1) {
                 if (!$validate['real_group']) {
                     $validate['real_group'] = $this->settings['member_group'];
                 } else {
                     if (!isset($this->caches['group_cache'][$validate['real_group']])) {
                         $validate['real_group'] = $this->settings['member_group'];
                     }
                 }
                 IPSMember::save($member['member_id'], array('members' => array('member_group_id' => intval($validate['real_group']))));
                 IPSCookie::set("member_id", $member['member_id'], 1);
                 IPSCookie::set("pass_hash", $member['member_login_key'], 1);
                 //-----------------------------------------
                 // Remove "dead" validation
                 //-----------------------------------------
                 $this->DB->delete('validating', "vid='" . $validate['vid'] . "' OR (member_id={$member['member_id']} AND email_chg=1)");
                 $this->registry->output->silentRedirect($this->settings['base_url'] . '&app=core&module=global&section=login&do=autologin&fromemail=1');
             }
         }
     }
 }
 /**
  * Account is validated
  *
  * @param	int		ID number
  * @param	string	md5( IPS Connect Key (see login method) . ID number )
  */
 public function validate($id, $key)
 {
     if ($key != md5($this->masterKey . $id)) {
         $this->_return(base64_encode($this->settings['board_url']), array('status' => 'BAD_KEY'));
     }
     $member = IPSMember::load(intval($id), 'none', 'id');
     if (!$member['member_id']) {
         $this->_return($redirect, array('status' => 'NO_USER'));
     }
     if ($member['member_group_id'] == ipsRegistry::$settings['auth_group']) {
         IPSMember::save($member['member_id'], array('members' => array('member_group_id' => ipsRegistry::$settings['member_group'], 'ipsconnect_revalidate_url' => '')));
     }
     ipsRegistry::DB()->delete('validating', "member_id={$member['member_id']} and new_reg=1");
     $this->_return($redirect, array('status' => 'SUCCESS'));
 }
Exemple #24
0
 /**
  * Delete a member's posts [process]
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _deletePostsDo()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $member_id = intval($this->request['member_id']);
     $delete_posts = intval($this->request['dposts']);
     $delete_topics = intval($this->request['dtopics']);
     $restart_for_posts = intval($this->request['restart_for_posts']);
     $end = intval($this->request['dpergo']) ? intval($this->request['dpergo']) : 50;
     $init = intval($this->request['init']);
     $done = 0;
     $start = intval($this->request['st']) >= 0 ? intval($this->request['st']) : 0;
     $forums_affected = array();
     $topics_affected = array();
     $img = '<img src="' . $this->settings['skin_acp_url'] . '/images/aff_tick.png" alt="-" /> ';
     $posts_deleted = 0;
     $topics_deleted = 0;
     //--------------------------------------------
     // NOT INIT YET?
     //--------------------------------------------
     if (!$init) {
         /* Right, first off, are we deleting anything? */
         if (!$delete_posts and !$delete_topics) {
             $this->registry->output->showError($this->lang->words['no_post_topic_sel_del']);
             return;
         }
         /* Okay, are we deleting topics AND posts? */
         if ($delete_posts and $delete_topics) {
             // It's silly to try and do this all in one go, so
             // we'll delete topics first and start again for posts
             $delete_posts = 0;
             $restart_for_posts = 1;
         }
         $url = $this->settings['base_url'] . '&' . $this->form_code_js . "&do=deleteposts_process&dpergo=" . $this->request['dpergo'] . "&st=0" . "&init=1" . "&dposts={$delete_posts}" . "&dtopics={$delete_topics}" . "&member_id={$member_id}" . "&name={$this->request['name']}" . "&restart_for_posts={$restart_for_posts}";
         $this->registry->output->multipleRedirectInit($url);
     }
     //--------------------------------------------
     // Not loaded the func?
     //--------------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/itemmarking/classItemMarking.php', 'classItemMarking');
     $this->registry->setClass('classItemMarking', new $classToLoad($this->registry));
     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums');
     $mod_func = new $classToLoad($this->registry);
     //-----------------------------------------
     // Avoid limit...
     //-----------------------------------------
     if ($member_id) {
         $member = IPSMember::load($member_id, 'core');
         $this->registry->output->extra_nav[] = array('', $this->lang->words['mem_delete_title']);
         $this->registry->output->extra_nav[] = array("{$this->settings['_base_url']}app=members&module=members&section=members&do=viewmember&member_id={$member_id}", $member['members_display_name']);
         $topicWhere = 't.starter_id=' . $member_id;
         $postsWhere = 'p.author_id=' . $member_id;
     } else {
         $member = array('member_id' => 0, 'name' => $this->request['name']);
         $name = $this->DB->addSlashes($this->request['name']);
         $topicWhere = "t.starter_id=0 AND t.starter_name='{$name}'";
         $postsWhere = "p.author_id=0 AND p.author_name='{$name}'";
     }
     /* Delete posts */
     if ($delete_posts) {
         $this->DB->build(array('select' => 'p.*', 'from' => array('posts' => 'p'), 'where' => $postsWhere, 'order' => 'p.pid ASC', 'add_join' => array(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id', 'type' => 'left'))));
     } elseif ($delete_topics) {
         $this->DB->build(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => $topicWhere, 'order' => 't.tid ASC', 'add_join' => array(array('select' => 'p.*', 'from' => array('posts' => 'p'), 'where' => 't.topic_firstpost=p.pid', 'type' => 'left'))));
     }
     $outer = $this->DB->execute();
     //-----------------------------------------
     // Process...
     //-----------------------------------------
     while ($r = $this->DB->fetch($outer)) {
         //-----------------------------------------
         // Copy record to topic array
         //-----------------------------------------
         $topic = $r;
         //-----------------------------------------
         // No longer a topic?
         //-----------------------------------------
         if (!$topic['tid']) {
             //-----------------------------------------
             // Cleanup - might as well remove the orphaned post
             // or the ACP will always show posts to delete that
             // it won't be able to delete
             //-----------------------------------------
             if ($topic['pid']) {
                 $this->DB->delete('posts', 'pid=' . $topic['pid']);
             }
             continue;
         }
         $done++;
         //-----------------------------------------
         // Get number of MID posters
         //-----------------------------------------
         $topic_i_posted = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => array('posts' => 'p'), 'where' => $postsWhere . ' AND topic_id=' . $r['tid']));
         //-----------------------------------------
         // Aready deleted this topic?
         //-----------------------------------------
         if (!$topic_i_posted['count']) {
             if ($delete_topics && $topic['state'] == 'link') {
                 /* We'll catch this below */
             } else {
                 continue;
             }
         }
         //-----------------------------------------
         // First check: Our topic and no other replies?
         //-----------------------------------------
         if (($member_id and $topic['starter_id'] == $member_id or !$member_id and !$topic['starter_id'] and $topic['starter_name'] == $this->request['name']) and $topic_i_posted['count'] == $topic['posts'] + 1) {
             //-----------------------------------------
             // Ok, deleting topics or posts?
             //-----------------------------------------
             if ($delete_posts or $delete_topics) {
                 $mod_func->topicDeleteFromDB($r['tid'], TRUE);
                 $forums_affected[$topic['forum_id']] = $topic['forum_id'];
                 $topics_deleted++;
                 $posts_deleted += $topic_i_posted['count'];
             }
         } else {
             if (($member_id and $topic['starter_id'] == $member_id or !$member_id and !$topic['starter_id'] and $topic['starter_name'] == $this->request['name']) and $delete_topics) {
                 $mod_func->topicDeleteFromDB($r['tid'], TRUE);
                 $forums_affected[$topic['forum_id']] = $topic['forum_id'];
                 $topics_deleted++;
                 $posts_deleted += $topic['posts'] + 1;
             } else {
                 if ($delete_posts and !$r['new_topic'] and $r['pid']) {
                     $mod_func->postDeleteFromDb($r['pid'], TRUE, TRUE);
                     $forums_affected[$topic['forum_id']] = $topic['forum_id'];
                     $topics_affected[$topic['tid']] = $topic['tid'];
                     $posts_deleted++;
                 }
             }
         }
     }
     //-----------------------------------------
     // Rebuild topics and forums
     //-----------------------------------------
     if (count($topics_affected)) {
         foreach ($topics_affected as $tid) {
             $mod_func->rebuildTopic($tid, 0);
         }
     }
     if (count($forums_affected)) {
         foreach ($forums_affected as $fid) {
             $mod_func->forumRecount($fid);
         }
     }
     //-----------------------------------------
     // Finish - or more?...
     //-----------------------------------------
     if (!$done) {
         //--------------------------------------
         // Hang on there! Do we need to do posts as well?
         //--------------------------------------
         if ($this->request['restart_for_posts']) {
             $url = $this->settings['base_url'] . '&' . $this->form_code_js . "&do=deleteposts_process&dpergo=" . $this->request['dpergo'] . "&st=0" . "&init=1" . "&dposts=1" . "&dtopics=0" . "&member_id={$member_id}" . "&name={$this->request['name']}" . "&restart_for_posts=0";
             $this->registry->output->multipleRedirectHit($url, $this->lang->words['mem_posts_next_step']);
         }
         //-----------------------------------------
         // Recount stats..
         //-----------------------------------------
         $this->cache->rebuildCache('stats', 'global');
         //-----------------------------------------
         // Reset member's posts
         //-----------------------------------------
         $forums = array();
         foreach ($this->registry->class_forums->forum_by_id as $data) {
             if (!$data['inc_postcount']) {
                 $forums[] = $data['id'];
             }
         }
         $_queued = $this->registry->class_forums->fetchPostHiddenQuery(array('visible'), 'p.');
         if (!count($forums)) {
             $count = $this->DB->buildAndFetch(array('select' => 'count(*) as count', 'from' => 'posts p', 'where' => $_queued . ' AND ' . $postsWhere));
         } else {
             $count = $this->DB->buildAndFetch(array('select' => 'count(p.pid) as count', 'from' => array('posts' => 'p'), 'where' => $_queued . ' AND ' . $postsWhere . ' AND t.forum_id NOT IN (' . implode(",", $forums) . ')', 'add_join' => array(array('type' => 'left', 'from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id'))));
         }
         $new_post_count = intval($count['count']);
         $this->registry->adminFunctions->saveAdminLog(sprintf($this->lang->words['member_posts_deleted'], $member_id ? $member['members_display_name'] : $this->request['name']));
         IPSMember::save($member_id, array('core' => array('posts' => $new_post_count)));
         $this->registry->output->multipleRedirectFinish($this->lang->words['mem_posts_process_done']);
     } else {
         //-----------------------------------------
         // More..
         //-----------------------------------------
         $next = $start + $end;
         $url = $this->settings['base_url'] . '&' . $this->form_code_js . "&do=deleteposts_process&dpergo={$end}" . "&st={$next}" . "&init=1" . "&dposts={$delete_posts}" . "&dtopics={$delete_topics}" . "&member_id={$member_id}" . "&name={$this->request['name']}" . "&restart_for_posts={$restart_for_posts}";
         $text = sprintf($this->lang->words['mem_posts_process_more'], $end, $posts_deleted, $topics_deleted);
         $this->registry->output->multipleRedirectHit($url, $img . ' ' . $text);
     }
 }
Exemple #25
0
 /**
  * Clean up the converted data
  *
  * @access	public
  * @param	string		new password
  * @return	@e void
  */
 public function cleanConvertData($new_pass)
 {
     IPSMember::save($this->_memberData['email'], array('core' => array('misc' => '', $this->password_field => '')), 'email');
     IPSMember::updatePassword($this->_memberData['email'], $new_pass);
 }
 /**
  * Get a user's session
  * @param int $memberId
  */
 public function getUserSession($memberId)
 {
     $session = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_generator_sessions', 'where' => 'sg_member_id=' . intval($memberId)));
     if (!empty($session['sg_session_id'])) {
         if (IPSLib::isSerialized($session['sg_data'])) {
             $session['sg_data_array'] = unserialize($session['sg_data']);
             if (IPSLib::isSerialized($session['sg_data_array']['set_skin_gen_data'])) {
                 $session['skin_gen_data'] = unserialize($session['sg_data_array']['set_skin_gen_data']);
             }
         }
         return $session;
     } else {
         /* Prevent this from loading again */
         IPSMember::save($memberId, array('core' => array('bw_using_skin_gen' => 0)));
         return false;
     }
 }
 /**
  * Fetch a skin based on user's incoming data (user-agent, URL) or via other params
  *
  * The priority chain goes like this:
  *
  * Incoming Gateway file (index.php / xml.php / rss.php, etc) filters out some skins, then:
  * - User Agent
  * - URL Remap
  * - App Specific
  * - Member specific
  * - Default skin
  *
  * @access	protected
  * @return	int			ID of skin to use
  */
 protected function _fetchUserSkin()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $useSkinID = FALSE;
     //-----------------------------------------
     // Unlocking a user-agent?
     //-----------------------------------------
     if (isset($this->request['unlockUserAgent']) and $this->request['unlockUserAgent']) {
         $this->member->updateMySession(array('uagent_bypass' => 1));
         /* Set cookie */
         IPSCookie::set("uagent_bypass", 1, -1);
     }
     //-----------------------------------------
     // Changing a skin?
     //-----------------------------------------
     if (isset($this->request['settingNewSkin']) and $this->request['settingNewSkin'] and $this->settings['allow_skins'] and $this->request['k'] == $this->member->form_hash) {
         $_id = intval($this->request['settingNewSkin']);
         /* Rudimentaty check */
         if ($this->allSkins[$_id]['_youCanUse'] and $this->allSkins[$_id]['_gatewayExclude'] !== TRUE) {
             if ($this->memberData['member_id']) {
                 /* Update... */
                 IPSMember::save($this->memberData['member_id'], array('core' => array('skin' => $_id)));
             } else {
                 IPSCookie::set('guestSkinChoice', $_id);
             }
             /* Update member row */
             $this->memberData['skin'] = $_id;
         }
     }
     //-----------------------------------------
     // Ok, lets get a skin!
     //-----------------------------------------
     foreach (array('_fetchSkinByUserAgent', '_fetchSkinByURLMap', '_fetchSkinByApp', '_fetchSkinByMemberPrefs', '_fetchSkinByDefault') as $function) {
         $useSkinID = $this->{$function}();
         if ($useSkinID !== FALSE) {
             break;
         }
     }
     //-----------------------------------------
     // Return it...
     //-----------------------------------------
     return $useSkinID;
 }
 /**
  * Saves the member's avatar
  *
  * @param		INT			Member's ID to save
  * @param		string		Upload field name [Default is "upload_avatar"]
  * @param		string		Avatar URL Field [Default is "avatar_url"]
  * @param		string		Gallery Avatar Directory Field [Default is "avatar_gallery"]
  * @param		string		Gallery Avatar Image Field [Default is "avatar_image"]
  * @author		Brandon Farber, Stolen By Matt 'Haxor' Mecham
  * <code>
  * Excepton Codes:
  * NO_MEMBER_ID:				A valid member ID was not passed.
  * NO_PERMISSION:				You do not have permission to change the avatar
  * UPLOAD_NO_IMAGE:				Nothing to upload
  * UPLOAD_INVALID_FILE_EXT:		Incorrect file extension (not an image)
  * UPLOAD_TOO_LARGE:			Upload is larger than allowed
  * UPLOAD_CANT_BE_MOVED:		Upload cannot be moved into the uploads directory
  * UPLOAD_NOT_IMAGE:			Upload is not an image, despite what the file extension says!
  * NO_AVATAR_TO_SAVE:			Nothing to save!
  * </code>
  */
 public function saveNewAvatar($member_id, $uploadFieldName = 'upload_avatar', $urlFieldName = 'avatar_url', $galleryFieldName = 'avatar_gallery', $avatarGalleryImage = 'avatar_image', $gravatarFieldName = 'gravatar_email')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $avatar = array();
     list($p_width, $p_height) = explode("x", strtolower($this->settings['avatar_dims']));
     if (!$member_id) {
         throw new Exception("NO_MEMBER_ID");
     }
     $member = IPSMember::load($member_id, 'extendedProfile,groups');
     if (!$member['member_id']) {
         throw new Exception("NO_MEMBER_ID");
     }
     //-----------------------------------------
     // Allowed to upload pics for administrators?
     //-----------------------------------------
     if (IPS_AREA != 'public') {
         if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_photo_admin', 'members', 'members')) {
             throw new Exception("NO_PERMISSION");
         }
     }
     //-----------------------------------------
     // Upload?
     //-----------------------------------------
     if ($_FILES[$uploadFieldName]['name'] != "" and $_FILES[$uploadFieldName]['name'] != "none") {
         $this->settings['upload_dir'] = str_replace('&#46;', '.', $this->settings['upload_dir']);
         $real_name = 'av-' . $member_id;
         require_once IPS_KERNEL_PATH . 'classUpload.php';
         $upload = new classUpload();
         $upload->out_file_name = $real_name;
         $upload->out_file_dir = $this->settings['upload_dir'];
         $upload->max_file_size = $this->settings['avup_size_max'] * 1024 * 8;
         // Allow xtra for compression
         $upload->upload_form_field = $uploadFieldName;
         //-----------------------------------------
         // 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
                     throw new Exception("UPLOAD_NO_IMAGE");
                     break;
                 case 2:
                     // Invalid file ext
                     throw new Exception("UPLOAD_INVALID_FILE_EXT");
                     break;
                 case 3:
                     // Too big...
                     throw new Exception("UPLOAD_TOO_LARGE");
                     break;
                 case 4:
                     // Cannot move uploaded file
                     throw new Exception("UPLOAD_CANT_BE_MOVED");
                     break;
                 case 5:
                     // Possible XSS attack (image isn't an image)
                     throw new Exception("UPLOAD_NOT_IMAGE");
                     break;
             }
         }
         $real_name = $upload->parsed_file_name;
         $im = array();
         if (!$this->settings['disable_ipbsize'] and $upload->file_extension != '.swf') {
             $imageDimensions = getimagesize($this->settings['upload_dir'] . '/' . $real_name);
             if ($imageDimensions[0] > $p_width or $imageDimensions[1] > $p_height) {
                 require_once IPS_KERNEL_PATH . "classImage.php";
                 require_once IPS_KERNEL_PATH . "classImageGd.php";
                 $image = new classImageGd();
                 $image->init(array('image_path' => $this->settings['upload_dir'], 'image_file' => $real_name));
                 $return = $image->resizeImage($p_width, $p_height);
                 $image->writeImage($this->settings['upload_dir'] . '/' . $real_name);
                 $im['img_width'] = $return['newWidth'] ? $return['newWidth'] : $image->cur_dimensions['width'];
                 $im['img_height'] = $return['newHeight'] ? $return['newHeight'] : $image->cur_dimensions['height'];
             } else {
                 $im['img_width'] = $imageDimensions[0];
                 $im['img_height'] = $imageDimensions[1];
             }
         } else {
             $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;
         }
         //-----------------------------------------
         // Set the "real" avatar..
         //-----------------------------------------
         $avatar['avatar_location'] = $real_name;
         $avatar['avatar_size'] = $im['img_width'] . 'x' . $im['img_height'];
         $avatar['avatar_type'] = 'upload';
     } else {
         if ($this->request[$urlFieldName] and IPSText::xssCheckUrl($this->request[$urlFieldName]) === true) {
             $ext = explode(",", $this->settings['avatar_ext']);
             $checked = 0;
             $av_ext = preg_replace("/^.*\\.(\\S+)\$/", "\\1", $this->request[$urlFieldName]);
             foreach ($ext as $v) {
                 if (strtolower($v) == strtolower($av_ext)) {
                     if ($v == 'swf' and $this->settings['disable_flash']) {
                         throw new Exception("INVALID_FILE_EXT");
                     }
                     $checked = 1;
                     break;
                 }
             }
             if ($checked != 1) {
                 throw new Exception("INVALID_FILE_EXT");
             }
             if (!$this->settings['disable_ipbsize']) {
                 if (!($img_size = @getimagesize($this->request[$urlFieldName]))) {
                     $img_size[0] = $p_width;
                     $img_size[1] = $p_height;
                 }
                 $im = IPSLib::scaleImage(array('max_width' => $p_width, 'max_height' => $p_height, 'cur_width' => $img_size[0], 'cur_height' => $img_size[1]));
             } else {
                 $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;
             }
             $avatar['avatar_location'] = trim($this->request[$urlFieldName]);
             $avatar['avatar_size'] = $im['img_width'] . 'x' . $im['img_height'];
             $avatar['avatar_type'] = 'url';
         } else {
             if (isset($this->request[$galleryFieldName]) and $this->request[$avatarGalleryImage]) {
                 $directory = '';
                 if ($this->request[$galleryFieldName]) {
                     $directory = preg_replace("/[^\\s\\w_-]/", "", urldecode($this->request[$galleryFieldName]));
                     if ($directory) {
                         $directory .= '/';
                     }
                 }
                 $filename = preg_replace("/[^\\s\\w\\._\\-\\[\\]\\(\\)]/", "", urldecode($this->request[$avatarGalleryImage]));
                 if (file_exists(DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_avatars/' . $directory . $filename)) {
                     $avatar['avatar_location'] = $directory . $filename;
                     $avatar['avatar_size'] = '';
                     $avatar['avatar_type'] = 'local';
                 }
             } else {
                 if ($this->request[$gravatarFieldName] && $this->request[$gravatarFieldName] && $this->settings['allow_gravatars']) {
                     $avatar['avatar_location'] = strtolower($this->request[$gravatarFieldName]);
                     $avatar['avatar_type'] = 'gravatar';
                 }
             }
         }
     }
     //-----------------------------------------
     // No avatar image?
     //-----------------------------------------
     if (!count($avatar)) {
         throw new Exception("NO_AVATAR_TO_SAVE");
     } else {
         if ($avatar['avatar_type'] != 'upload') {
             foreach (array('swf', 'jpg', 'jpeg', 'gif', 'png') as $ext) {
                 if (@file_exists($this->settings['upload_dir'] . "/av-" . $member_id . "." . $ext)) {
                     @unlink($this->settings['upload_dir'] . "/av-" . $member_id . "." . $ext);
                 }
             }
         }
     }
     //-----------------------------------------
     // Store and redirect
     //-----------------------------------------
     IPSMember::save($member_id, array('extendedProfile' => $avatar));
     return TRUE;
 }
 /**
  * Authenticate the request
  *
  * @access	public
  * @param	string		Username
  * @param	string		Email Address
  * @param	string		Password
  * @return	boolean		Authentication successful
  */
 public function authenticate($username, $email_address, $password)
 {
     //-----------------------------------------
     // Check admin authentication request
     //-----------------------------------------
     if ($this->is_admin_auth) {
         $this->adminAuthLocal($username, $email_address, $password);
         if ($this->return_code == 'SUCCESS') {
             return true;
         }
     }
     //-----------------------------------------
     // Set some OpenID stuff
     //-----------------------------------------
     $this->auth_errors = array();
     $pape_policy_uris = array(PAPE_AUTH_MULTI_FACTOR_PHYSICAL, PAPE_AUTH_MULTI_FACTOR, PAPE_AUTH_PHISHING_RESISTANT);
     session_start();
     //-----------------------------------------
     // OK?
     //-----------------------------------------
     if (!$this->request['firstpass']) {
         $this->_doFirstPass();
     } else {
         $this->_checkFirstPass();
     }
     if (count($this->auth_errors)) {
         $this->return_code = $this->return_code ? $this->return_code : 'NO_USER';
         return false;
     }
     if (!$this->data_store['email']) {
         $this->return_code = 'NO_USER';
         return false;
     }
     $this->_loadMember($this->data_store['fullurl'], $this->data_store['email']);
     if ($this->member_data['member_id']) {
         $this->return_code = 'SUCCESS';
         if (strtolower(trim($this->data_store['email'])) != strtolower($this->member_data['email'])) {
             $check = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'members', 'where' => "email='" . strtolower(trim($this->data_store['email'])) . "'"));
             if ($check['member_id']) {
                 $this->data_store['email'] = $this->member_data['email'];
             }
         }
         //-----------------------------------------
         // Set Birthday fields if available
         //-----------------------------------------
         $dob = trim($this->data_store['dob']);
         $bday_day = 0;
         $bday_mon = 0;
         $bday_year = 0;
         if ($dob) {
             list($bday_year, $bday_mon, $bday_day) = explode('-', $dob);
         }
         $core = array('email' => trim($this->data_store['email']), 'bday_year' => $bday_year, 'bday_month' => $bday_mon, 'bday_day' => $bday_day, 'identity_url' => $this->data_store['fullurl']);
         //-----------------------------------------
         // Update the display name and name, if not taken
         //-----------------------------------------
         try {
             if (IPSMember::getFunction()->checkNameExists($this->data_store['nickname'], $this->member_data) === false) {
                 $core['members_display_name'] = trim($this->data_store['nickname']);
                 $core['members_l_display_name'] = strtolower(trim($this->data_store['nickname']));
                 //-----------------------------------------
                 // If our display name is changing, store record
                 //-----------------------------------------
                 if ($core['members_display_name'] != $this->member_data['members_display_name']) {
                     $this->DB->insert('dnames_change', array('dname_member_id' => $this->member_data['member_id'], 'dname_date' => time(), 'dname_ip_address' => $this->member->ip_address, 'dname_previous' => $this->member_data['members_display_name'], 'dname_current' => $core['members_display_name']));
                 }
                 $this->member_data['members_display_name'] = trim($this->data_store['nickname']);
                 $this->member_data['members_l_display_name'] = strtolower(trim($this->data_store['nickname']));
             }
         } catch (Exception $e) {
         }
         try {
             if (IPSMember::getFunction()->checkNameExists($this->data_store['nickname'], $this->member_data, 'name') === false) {
                 $core['name'] = trim($this->data_store['nickname']);
                 $core['members_l_username'] = strtolower(trim($this->data_store['nickname']));
                 $this->member_data['name'] = trim($this->data_store['nickname']);
                 $this->member_data['members_l_username'] = strtolower(trim($this->data_store['nickname']));
             }
         } catch (Exception $e) {
         }
         IPSMember::save($this->member_data['email'], array('core' => $core));
         $this->member_data['identity_url'] = $this->data_store['fullurl'];
         $this->member_data['email'] = trim($this->data_store['email']);
         $this->member_data['bday_year'] = $bday_year;
         $this->member_data['bday_month'] = $bday_month;
         $this->member_data['bday_day'] = $bday_day;
     } else {
         //-----------------------------------------
         // Set main fields
         //-----------------------------------------
         $email = trim($this->data_store['email']);
         $name = trim($this->data_store['nickname']);
         $dob = trim($this->data_store['dob']);
         $timenow = time();
         //-----------------------------------------
         // Set Birthday fields if available
         //-----------------------------------------
         $bday_day = 0;
         $bday_mon = 0;
         $bday_year = 0;
         if ($dob) {
             list($bday_year, $bday_mon, $bday_day) = explode('-', $dob);
         }
         if (strtolower(trim($this->data_store['email'])) != strtolower($this->member_data['email'])) {
             $check = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'members', 'where' => "email='" . strtolower(trim($this->data_store['email'])) . "'"));
             if ($check['member_id']) {
                 $email = '';
             }
         }
         if (strtolower(trim($this->data_store['nickname'])) != $this->member_data['members_l_username']) {
             $check = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'members', 'where' => "members_l_username='******'nickname'])) . "'"));
             if ($check['member_id']) {
                 $name = '';
             }
         }
         $this->member_data = $this->createLocalMember(array('members' => array('email' => $email, 'name' => $name, 'members_l_username' => strtolower($name), 'members_display_name' => $name, 'members_l_display_name' => strtolower($name), 'joined' => time(), 'bday_day' => $bday_day, 'bday_month' => $bday_mon, 'bday_year' => $bday_year, 'members_created_remote' => 1, 'identity_url' => $this->data_store['fullurl']), 'profile_portal' => array()));
         $this->return_code = 'SUCCESS';
     }
     if ($this->data_store['referrer']) {
         $this->request['referer'] = $this->data_store['referrer'];
     }
     if ($this->data_store['cookiedate']) {
         $this->request['rememberMe'] = $this->data_store['cookiedate'];
     }
     if ($this->data_store['privacy']) {
         $this->request['anonymous'] = $this->data_store['privacy'];
     }
     return $this->return_code;
 }
Exemple #30
0
 /**
  * Log a user out
  *
  * @param	integer		Flag to check md5 key
  * @return	mixed		Error message or array [0=immediate|redirect, 1=words to show, 2=URL to send to]
  */
 public function doLogout($check_key = true)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     if ($check_key) {
         $key = $this->request['k'];
         # Check for funny business
         if ($key != $this->member->form_hash) {
             $this->registry->getClass('output')->showError('bad_logout_key', 2012);
         }
     }
     //-----------------------------------------
     // Set some cookies
     //-----------------------------------------
     IPSCookie::set("member_id", "0", 1, 0, FALSE, TRUE);
     IPSCookie::set("pass_hash", "0", 1, 0, FALSE, TRUE);
     if (IPSCookie::get("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'))) {
         IPSCookie::set("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'), '0', 1, 0, FALSE, FALSE);
     }
     //-----------------------------------------
     // IPS Connect
     //-----------------------------------------
     foreach ($this->caches['login_methods'] as $k => $data) {
         if ($data['login_folder_name'] == 'ipsconnect' and $data['login_enabled']) {
             $ipsConnectSettings = unserialize($data['login_custom_config']);
             IPSCookie::set("ipsconnect_" . md5($ipsConnectSettings['master_url']), '0', 1, 0, FALSE, FALSE);
         }
     }
     if (is_array($_COOKIE)) {
         foreach ($_COOKIE as $cookie => $value) {
             if (stripos($cookie, $this->settings['cookie_id'] . 'ipbforumpass') !== false and !strstr($value, 'mobileApp')) {
                 IPSCookie::set(str_replace($this->settings['cookie_id'], "", $cookie), '-', -1);
             }
         }
     }
     //-----------------------------------------
     // Do it..
     //-----------------------------------------
     $this->member->sessionClass()->convertMemberToGuest();
     $privacy = intval(IPSMember::isLoggedInAnon($this->memberData));
     IPSMember::save($this->memberData['member_id'], array('core' => array('login_anonymous' => "{$privacy}&0", 'last_activity' => IPS_UNIX_TIME_NOW)));
     //-----------------------------------------
     // Logout callbacks...
     //-----------------------------------------
     IPSLib::runMemberSync('onLogOut', $this->memberData);
     $this->han_login->logoutCallback($this->memberData);
     //-----------------------------------------
     // Return..
     //-----------------------------------------
     $url = "";
     if ($this->request['return'] and $this->request['return'] != "") {
         $return = urldecode($this->request['return']);
         if (strpos($return, "http://") === 0) {
             return array('immediate', '', $return);
         }
     }
     return array('redirect', $this->lang->words['thanks_for_logout'], $this->settings['board_url']);
 }