/**
  * Toggle side panel on/off without JS
  *
  * @access	public
  * @return	void
  * @see		The Dark Knight (it was an awesome movie)
  */
 public function _toggleSidePanel()
 {
     $current = IPSCookie::get('hide_sidebar');
     $new = $current ? 0 : 1;
     IPSCookie::set('hide_sidebar', $new);
     $this->registry->getClass('output')->silentRedirect($this->settings['base_url']);
 }
Ejemplo n.º 2
0
 /**
  * Toggle side panel on/off without JS
  *
  * @return	@e void
  * @see		The Dark Knight (it was an awesome movie)
  */
 public function _toggleSidePanel()
 {
     /* Security Check */
     if ($this->request['secure_key'] != $this->member->form_hash) {
         $this->registry->output->showError('usercp_forums_bad_key', 102998, null, null, 403);
     }
     $current = IPSCookie::get('hide_sidebar');
     $new = $current ? 0 : 1;
     IPSCookie::set('hide_sidebar', $new);
     $this->registry->getClass('output')->silentRedirect($this->settings['base_url'] . 'act=idx', 'false');
 }
Ejemplo n.º 3
0
 /**
  * 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);
 }
Ejemplo n.º 4
0
 /**
  * Figure out what api is being called
  *
  * @return	@e void
  */
 public function dispatch()
 {
     /* Force a cookie to identify as a mobile app */
     if (!$this->request['dontSetCookie']) {
         IPSCookie::set("mobileApp", 'true', -1);
     }
     /* Figure out the action */
     switch ($this->request['api']) {
         case 'getNotifications':
             $this->_handleGetNotifications();
             break;
         case 'toggleNotifications':
             $this->_handleToggleNotifications();
             break;
         case 'toggleNotificationKey':
             $this->_hanldeToggleNotificaionKey();
             break;
         case 'notificationTypes':
             $this->_handleNotificationTypes();
             break;
         case 'login':
             $this->_handleLogin();
             break;
         case 'postImage':
             $this->_handlePostImage();
             break;
         case 'postStatus':
             $this->_handlePostStatus();
             break;
         case 'postTopic':
             $this->_handlePostTopic();
             break;
         case 'postReply':
             $this->_handlePostReply();
             break;
         case 'getStyle':
             $this->_handleGetStyle();
             break;
         case 'getApns':
             $this->_getApns();
             break;
         default:
             $this->_invalidApi();
             break;
     }
 }
 /**
  * Converts a member session to a guest session
  *
  * @access	public
  * @return	string 		Current session ID
  */
 public function convertMemberToGuest()
 {
     /* Delete old sessions */
     $this->_destroySessions("ip_address='" . $this->_member->ip_address . "' AND id != '{$this->session_id}'");
     /* Update this session directly */
     $this->DB->update('sessions', array('member_name' => '', 'seo_name' => '', 'member_id' => 0, 'running_time' => time(), 'member_group' => $this->settings['guest_group']), "id='" . $this->session_id . "'", TRUE);
     /* Remove from update and delete array */
     unset($this->_sessionsToSave[$this->session_id]);
     unset($this->_sessionsToKill[$this->session_id]);
     /* Set cookie */
     IPSCookie::set("session_id", $this->session_id, -1);
     /* Save markers... */
     $this->registry->classItemMarking->writeMyMarkersToDB();
     IPSDebug::addLogMessage("convertMemberToGuest: {$this->session_id} " . serialize($data), 'sessions-' . $this->_memberData['member_id']);
     /* Set type */
     self::$data_store['_sessionType'] = 'update';
     return $this->session_id;
 }
Ejemplo n.º 6
0
 /**
  * Show more dialogue
  *
  * @param	integer		$relid		Relationship ID
  * @return	@e void
  */
 protected function _change()
 {
     $skinId = $this->request['skinId'];
     /* Make sure cookies are set */
     $this->settings['no_print_header'] = 0;
     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);
             /* Update member row */
             $this->memberData['skin'] = $skinId;
         }
     } else {
         if ($skinId == 'fullVersion') {
             /* Set cookie */
             IPSCookie::set("uagent_bypass", 1, -1);
             IPSCookie::set("mobileBrowser", 0, -1);
             /* Set member pref if not a mobile app */
             if ($this->memberData['userAgentType'] != 'mobileAppLegacy' && $this->memberData['userAgentType'] != 'mobileApp') {
                 /* Got one set by default for this gateway? */
                 foreach ($this->registry->output->allSkins as $data) {
                     /* Can use with this output format? */
                     if ($data['_gatewayExclude'] !== FALSE) {
                         continue;
                     }
                     /* Is default for our current gateway? */
                     if ($data['set_is_default'] && $this->caches['outputformats'][$data['set_output_format']]['gateway_file'] == IPS_PUBLIC_SCRIPT) {
                         $skinId = $data['set_id'];
                         break;
                     }
                 }
                 /* Update... */
                 if ($this->memberData['member_id']) {
                     IPSMember::save($this->memberData['member_id'], array('core' => array('skin' => $skinId)));
                 } else {
                     IPSCookie::set('guestSkinChoice', $skinId);
                 }
             }
         } 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);
                 }
             }
         }
     }
     $this->returnJsonArray(array('status' => 'ok'));
 }
Ejemplo n.º 7
0
 /**
  * Topic multi-moderation
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _multiTopicModify()
 {
     /* init */
     $done = false;
     /* Check these first */
     switch ($this->request['tact']) {
         case 't_approve':
             $this->_topicsManage('approve_unapproved');
             $done = true;
             break;
         case 't_delete_approve':
             $this->_topicsManage('delete_unapproved');
             $done = true;
             break;
         case 't_restore':
             $this->_topicsManage('restore_deleted');
             $done = true;
             break;
         case 't_delete_softed':
             $this->_topicsManage('delete_deleted');
             $done = true;
             break;
     }
     $this->tids = $this->_getIds();
     if (count($this->tids) and $done !== true) {
         switch ($this->request['tact']) {
             case 'close':
                 $this->_multiAlterTopics('close_topic', "state='closed'");
                 break;
             case 'open':
                 $this->_multiAlterTopics('open_topic', "state='open'");
                 break;
             case 'pin':
                 $this->_multiAlterTopics('pin_topic', "pinned=1");
                 break;
             case 'unpin':
                 $this->_multiAlterTopics('unpin_topic', "pinned=0");
                 break;
             case 'approve':
                 $this->_multiAlterTopics('topic_q', $this->registry->getClass('class_forums')->fetchTopicHiddenQuery(array('visible'), ''));
                 break;
             case 'unapprove':
                 $this->_multiAlterTopics('topic_q', $this->registry->getClass('class_forums')->fetchTopicHiddenQuery(array('hidden'), ''));
                 break;
             case 'delete':
                 $this->_multiAlterDeleteSplash();
                 break;
             case 'deletedo':
                 $this->_multiAlterTopics('delete_topic');
                 break;
             case 'sdelete':
                 $this->_multiSoftDeleteTopics(1, $this->request['deleteReason']);
                 break;
             case 'sundelete':
                 $this->_multiSoftDeleteTopics(0);
                 break;
             case 'move':
                 $this->_multiStartCheckedMove();
                 return;
                 break;
             case 'domove':
                 $this->_multiCompleteCheckedMove();
                 break;
             case 'merge':
                 if ($this->_multiTopicMerge() === FALSE) {
                     return;
                 }
                 break;
             default:
                 $this->_multiTopicMmod();
                 break;
         }
     }
     IPSCookie::set('modtids', '', 0);
     /* From search? */
     if ($this->fromSearch and $this->returnUrl) {
         if ($this->request['nr']) {
             $this->registry->output->silentRedirect($this->returnUrl);
         } else {
             $this->registry->output->redirectScreen($this->lang->words['cp_redirect_topics'], $this->returnUrl);
         }
     } else {
         if ($this->request['return']) {
             $_bits = explode(':', $this->request['return']);
             if (count($_bits) and $_bits[0] == 'modcp') {
                 $this->registry->output->redirectScreen($this->lang->words['cp_redirect_posts'], $this->settings['base_url'] . "app=core&module=modcp&fromapp=forums&tab=" . $_bits[1] . 'topics');
             }
         } else {
             if ($this->forum['id']) {
                 $url = "showforum=" . $this->forum['id'];
                 $url = $this->request['st'] ? "showforum=" . $this->forum['id'] . '&page=' . $this->request['page'] : $url;
                 if ($this->request['nr']) {
                     $this->registry->output->silentRedirect($this->settings['base_url'] . $url, $this->forum['name_seo'], 'showforum');
                 } else {
                     $this->registry->output->redirectScreen($this->lang->words['cp_redirect_topics'], $this->settings['base_url'] . $url, $this->forum['name_seo'], 'showforum');
                 }
             }
         }
     }
 }
 //-----------------------------------------
 // Get converge
 //-----------------------------------------
 $converge = $registry->DB()->buildAndFetch(array('select' => '*', 'from' => 'converge_local', 'where' => "converge_active=1 AND converge_product_id=" . $product_id));
 //-----------------------------------------
 // Get member....
 //-----------------------------------------
 $session = $registry->DB()->buildAndFetch(array('select' => '*', 'from' => 'sessions', 'where' => "id='" . $session_id . "' AND member_id=" . $member_id));
 if ($session['member_id']) {
     $member = IPSMember::load($member_id);
     if (md5($member['member_login_key'] . $converge['converge_api_code']) == $key) {
         if ($set_cookies) {
             IPSCookie::set("member_id", $member['member_id'], 1);
             IPSCookie::set("pass_hash", $member['member_login_key'], 1);
         }
         IPSCookie::set("session_id", $session_id, -1);
     }
     //-----------------------------------------
     // Update session
     //-----------------------------------------
     $registry->DB()->update('sessions', array('browser' => $registry->member()->user_agent, 'ip_address' => $registry->member()->ip_address), "id='" . $session_id . "'");
 }
 //-----------------------------------------
 // Is this a partial member?
 // Not completed their sign in?
 //-----------------------------------------
 if ($member['members_created_remote']) {
     $pmember = $registry->DB()->buildAndFetch(array('select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id={$member['member_id']}"));
     if ($pmember['partial_member_id']) {
         ipsRegistry::getClass('output')->silentRedirect(ipsRegistry::$settings['board_url'] . '/index.' . ipsRegistry::$settings['php_ext'] . '?act=reg&do=complete_login&mid=' . $member['member_id'] . '&key=' . $pmember['partial_date']);
         exit;
 /**
  * Save cookie
  *
  * @access	protected
  * @param	string		Key name (leave blank to save out all cookies)
  * @return	@e void
  */
 protected function _saveCookie($key = '')
 {
     if (!$this->_useCookies) {
         return;
     }
     if ($key and is_array($this->_cookie[$key])) {
         IPSCookie::set($key, $this->_cookie[$key], 1);
     } else {
         foreach ($this->_cookie as $k => $v) {
             if (is_array($v) and !count($v)) {
                 /* Do we have a cookie? */
                 $test = IPSCookie::get($k);
                 if ($test) {
                     /* set a blank, non sticky cookie */
                     IPSCookie::set($k, '-', 0, -1);
                 } else {
                     continue;
                 }
             } else {
                 IPSDebug::addMessage('Cookie SAVED: ' . $k . ' - ' . $this->_compressCookie($v));
                 IPSCookie::set($k, $this->_compressCookie($v), 1);
             }
         }
     }
 }
 /**
  * Builds an array of forum data for use in the output template
  *
  * @access	public
  * @return	array
  **/
 public function renderForum()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['st'] = $this->request['changefilters'] ? 0 : (isset($this->request['st']) ? intval($this->request['st']) : 0);
     $announce_data = array();
     $topic_data = array();
     $other_data = array();
     $multi_mod_data = array();
     $footer_filter = array();
     //-----------------------------------------
     // Show?
     //-----------------------------------------
     if (isset($this->request['show']) and $this->request['show'] == 'sinceLastVisit') {
         $this->request['prune_day'] = 200;
     }
     //-----------------------------------------
     // Are we actually a moderator for this forum?
     //-----------------------------------------
     $mod = $this->memberData['forumsModeratorData'];
     if (!$this->memberData['g_is_supmod']) {
         if (!isset($mod[$this->forum['id']]) or !is_array($mod[$this->forum['id']])) {
             $this->memberData['is_mod'] = 0;
         }
     }
     //-----------------------------------------
     // Announcements
     //-----------------------------------------
     if (is_array($this->registry->cache()->getCache('announcements')) and count($this->registry->cache()->getCache('announcements'))) {
         $announcements = array();
         foreach ($this->registry->cache()->getCache('announcements') as $announce) {
             $order = $announce['announce_start'] ? $announce['announce_start'] . ',' . $announce['announce_id'] : $announce['announce_id'];
             if ($announce['announce_forum'] == '*') {
                 $announcements[$order] = $announce;
             } else {
                 if (strstr(',' . $announce['announce_forum'] . ',', ',' . $this->forum['id'] . ',')) {
                     $announcements[$order] = $announce;
                 }
             }
         }
         if (count($announcements)) {
             //-----------------------------------------
             // sort by start date
             //-----------------------------------------
             krsort($announcements);
             foreach ($announcements as $announce) {
                 if ($announce['announce_start']) {
                     $announce['announce_start'] = gmstrftime('%x', $announce['announce_start']);
                 } else {
                     $announce['announce_start'] = '--';
                 }
                 $announce['announce_title'] = IPSText::stripslashes($announce['announce_title']);
                 $announce['forum_id'] = $this->forum['id'];
                 $announce['announce_views'] = intval($announce['announce_views']);
                 $announce_data[] = $announce;
             }
             $this->forum['_showAnnouncementsBar'] = 1;
         }
     }
     //-----------------------------------------
     // Read topics
     //-----------------------------------------
     $First = intval($this->request['st']);
     //-----------------------------------------
     // Sort options
     //-----------------------------------------
     $cookie_prune = IPSCookie::get($this->forum['id'] . "_prune_day");
     $cookie_sort = IPSCookie::get($this->forum['id'] . "_sort_key");
     $cookie_sortb = IPSCookie::get($this->forum['id'] . "_sort_by");
     $cookie_fill = IPSCookie::get($this->forum['id'] . "_topicfilter");
     $prune_value = $this->selectVariable(array(1 => !empty($this->request['prune_day']) ? $this->request['prune_day'] : NULL, 2 => !empty($cookie_prune) ? $cookie_prune : NULL, 3 => $this->forum['prune'], 4 => '100'));
     $sort_key = $this->selectVariable(array(1 => !empty($this->request['sort_key']) ? $this->request['sort_key'] : NULL, 2 => !empty($cookie_sort) ? $cookie_sort : NULL, 3 => $this->forum['sort_key'], 4 => 'last_post'));
     $sort_by = $this->selectVariable(array(1 => !empty($this->request['sort_by']) ? $this->request['sort_by'] : NULL, 2 => !empty($cookie_sortb) ? $cookie_sortb : NULL, 3 => $this->forum['sort_order'], 4 => 'Z-A'));
     $topicfilter = $this->selectVariable(array(1 => !empty($this->request['topicfilter']) ? $this->request['topicfilter'] : NULL, 2 => !empty($cookie_fill) ? $cookie_fill : NULL, 3 => $this->forum['topicfilter'], 4 => 'all'));
     //print_r($this->request);exit;
     //print($cookie_sort);exit;
     if (!empty($this->request['remember'])) {
         if ($this->request['prune_day']) {
             IPSCookie::set($this->forum['id'] . "_prune_day", $this->request['prune_day']);
         }
         if ($this->request['sort_key']) {
             IPSCookie::set($this->forum['id'] . "_sort_key", $this->request['sort_key']);
         }
         if ($this->request['sort_by']) {
             IPSCookie::set($this->forum['id'] . "_sort_by", $this->request['sort_by']);
         }
         if ($this->request['topicfilter']) {
             IPSCookie::set($this->forum['id'] . "_topicfilter", $this->request['topicfilter']);
         }
     }
     //print $sort_key;exit;
     //-----------------------------------------
     // Figure out sort order, day cut off, etc
     //-----------------------------------------
     $Prune = $prune_value < 100 ? time() - $prune_value * 60 * 60 * 24 : (($prune_value == 200 and $this->memberData['member_id']) ? $this->memberData['last_visit'] : 0);
     $sort_keys = array('last_post' => 'sort_by_date', 'last_poster_name' => 'sort_by_last_poster', 'title' => 'sort_by_topic', 'starter_name' => 'sort_by_poster', 'start_date' => 'sort_by_start', 'topic_hasattach' => 'sort_by_attach', 'posts' => 'sort_by_replies', 'views' => 'sort_by_views');
     $prune_by_day = array('1' => 'show_today', '5' => 'show_5_days', '7' => 'show_7_days', '10' => 'show_10_days', '15' => 'show_15_days', '20' => 'show_20_days', '25' => 'show_25_days', '30' => 'show_30_days', '60' => 'show_60_days', '90' => 'show_90_days', '100' => 'show_all', '200' => 'show_last_visit');
     $sort_by_keys = array('Z-A' => 'descending_order', 'A-Z' => 'ascending_order');
     $filter_keys = array('all' => 'topicfilter_all', 'open' => 'topicfilter_open', 'hot' => 'topicfilter_hot', 'poll' => 'topicfilter_poll', 'locked' => 'topicfilter_locked', 'moved' => 'topicfilter_moved');
     if ($this->memberData['member_id']) {
         $filter_keys['istarted'] = 'topicfilter_istarted';
         $filter_keys['ireplied'] = 'topicfilter_ireplied';
     }
     //-----------------------------------------
     // check for any form funny business by wanna-be hackers
     //-----------------------------------------
     if (!isset($filter_keys[$topicfilter]) or !isset($sort_keys[$sort_key]) or !isset($prune_by_day[$prune_value]) or !isset($sort_by_keys[$sort_by])) {
         $this->registry->getClass('output')->showError('forums_bad_filter', 10339);
     }
     $r_sort_by = $sort_by == 'A-Z' ? 'ASC' : 'DESC';
     //-----------------------------------------
     // If sorting by starter, add secondary..
     //-----------------------------------------
     $sort_key_chk = $sort_key;
     if ($sort_key == 'starter_name') {
         $sort_key = "starter_name {$r_sort_by}, t.last_post DESC";
         $r_sort_by = '';
     }
     //-----------------------------------------
     // Additional queries?
     //-----------------------------------------
     $add_query_array = array();
     $add_query = "";
     switch ($topicfilter) {
         case 'all':
             break;
         case 'open':
             $add_query_array[] = "t.state='open'";
             break;
         case 'hot':
             $add_query_array[] = "t.state='open' AND t.posts + 1 >= " . intval($this->settings['hot_topic']);
             break;
         case 'locked':
             $add_query_array[] = "t.state='closed'";
             break;
         case 'moved':
             $add_query_array[] = "t.state='link'";
             break;
         case 'poll':
             $add_query_array[] = "(t.poll_state='open' OR t.poll_state=1)";
             break;
         default:
             break;
     }
     if (!$this->memberData['g_other_topics'] or $topicfilter == 'istarted' or !$this->forum['can_view_others'] and !$this->memberData['is_mod']) {
         $add_query_array[] = "t.starter_id='" . $this->memberData['member_id'] . "'";
     }
     $_SQL_EXTRA = '';
     $_SQL_APPROVED = '';
     $_SQL_AGE_PRUNE = '';
     if (count($add_query_array)) {
         $_SQL_EXTRA = ' AND ' . implode(' AND ', $add_query_array);
     }
     //-----------------------------------------
     // Moderator?
     //-----------------------------------------
     if (!$this->memberData['is_mod']) {
         $_SQL_APPROVED = ' AND t.approved=1';
     } else {
         $_SQL_APPROVED = '';
         //' AND t.approved IN (0,1)';	If you are an admin, it's not needed and eliminates a filesort in some cases
     }
     if ($Prune) {
         if ($prune_value == 200) {
             /* Just new content, don't show pinned, please */
             $_SQL_AGE_PRUNE = " AND (t.last_post > {$Prune})";
         } else {
             $_SQL_AGE_PRUNE = " AND (t.pinned=1 or t.last_post > {$Prune})";
         }
     }
     //-----------------------------------------
     // Query the database to see how many topics there are in the forum
     //-----------------------------------------
     if ($topicfilter == 'ireplied') {
         //-----------------------------------------
         // Checking topics we've replied to?
         //-----------------------------------------
         $this->DB->build(array('select' => 'COUNT(' . $this->DB->buildDistinct('p.topic_id') . ') as max', 'from' => array('topics' => 't'), 'where' => " t.forum_id={$this->forum['id']} AND p.author_id=" . $this->memberData['member_id'] . " AND p.new_topic=0" . $_SQL_APPROVED . $_SQL_AGE_PRUNE, 'add_join' => array(array('from' => array('posts' => 'p'), 'where' => 'p.topic_id=t.tid'))));
         $this->DB->execute();
         $total_possible = $this->DB->fetch();
     } else {
         if (($_SQL_EXTRA or $_SQL_AGE_PRUNE) and !$this->request['modfilter']) {
             $this->DB->build(array('select' => 'COUNT(*) as max', 'from' => 'topics t', 'where' => "t.forum_id=" . $this->forum['id'] . $_SQL_APPROVED . $_SQL_AGE_PRUNE . $_SQL_EXTRA));
             $this->DB->execute();
             $total_possible = $this->DB->fetch();
         } else {
             $total_possible['max'] = $this->memberData['is_mod'] ? $this->forum['topics'] + $this->forum['queued_topics'] : $this->forum['topics'];
             $Prune = 0;
         }
     }
     //-----------------------------------------
     // Generate the forum page span links
     //-----------------------------------------
     $this->forum['SHOW_PAGES'] = $this->registry->getClass('output')->generatePagination(array('totalItems' => $total_possible['max'], 'itemsPerPage' => $this->settings['display_max_topics'], 'currentStartValue' => $this->request['st'], 'seoTitle' => $this->forum['name_seo'], 'baseUrl' => "showforum=" . $this->forum['id'] . "&amp;prune_day={$prune_value}&amp;sort_by={$sort_by}&amp;sort_key={$sort_key_chk}&amp;topicfilter={$topicfilter}"));
     //-----------------------------------------
     // Start printing the page
     //-----------------------------------------
     $other_data = array('forum_data' => $this->forum, 'can_edit_topics' => $this->can_edit_topics, 'can_open_topics' => $this->can_open_topics, 'can_close_topics' => $this->can_close_topics);
     $total_topics_printed = 0;
     //-----------------------------------------
     // Get main topics
     //-----------------------------------------
     $topic_array = array();
     $topic_ids = array();
     $topic_sort = "";
     //-----------------------------------------
     // Mod filter?
     //-----------------------------------------
     $this->request['modfilter'] = isset($this->request['modfilter']) ? $this->request['modfilter'] : '';
     if ($this->request['modfilter'] == 'invisible_topics' and $this->memberData['is_mod']) {
         $topic_sort = 't.approved asc,';
     } else {
         if ($this->request['modfilter'] == 'invisible_posts' and $this->memberData['is_mod']) {
             $topic_sort = 't.topic_queuedposts desc,';
         } else {
             if ($this->request['modfilter'] == 'all' and $this->memberData['is_mod']) {
                 $topic_sort = 't.approved asc, t.topic_queuedposts desc,';
             }
         }
     }
     //-----------------------------------------
     // Cut off?
     //-----------------------------------------
     $parse_dots = 1;
     if ($topicfilter == 'ireplied') {
         //-----------------------------------------
         // Checking topics we've replied to?
         // No point in getting dots again...
         //-----------------------------------------
         $parse_dots = 0;
         // For some reason, mySQL doesn't like the distinct + t.* being in reverse order...
         $this->DB->build(array('select' => $this->DB->buildDistinct('p.author_id'), 'from' => array('topics' => 't'), 'where' => "t.forum_id=" . $this->forum['id'] . " AND t.pinned IN (0,1)" . $_SQL_APPROVED . $_SQL_AGE_PRUNE . " AND p.new_topic=0", 'order' => "t.pinned desc,{$topic_sort} t.{$sort_key} {$r_sort_by}", 'limit' => array(intval($First), intval($this->settings['display_max_topics'])), 'add_join' => array(array('select' => 't.*', 'from' => array('posts' => 'p'), 'where' => 'p.topic_id=t.tid AND p.author_id=' . $this->memberData['member_id']))));
         $this->DB->execute();
     } else {
         $this->DB->build(array('select' => '*', 'from' => 'topics t', 'where' => "t.forum_id=" . $this->forum['id'] . " AND t.pinned IN (0,1)" . $_SQL_APPROVED . $_SQL_AGE_PRUNE . $_SQL_EXTRA, 'order' => 't.pinned DESC, ' . $topic_sort . ' t.' . $sort_key . ' ' . $r_sort_by, 'limit' => array(intval($First), $this->settings['display_max_topics'])));
         $this->DB->execute();
     }
     while ($t = $this->DB->fetch()) {
         $topic_array[$t['tid']] = $t;
         $topic_ids[$t['tid']] = $t['tid'];
     }
     ksort($topic_ids);
     //-----------------------------------------
     // Are we dotty?
     //-----------------------------------------
     if ($this->settings['show_user_posted'] == 1 and $this->memberData['member_id'] and count($topic_ids) and $parse_dots) {
         $this->DB->build(array('select' => 'author_id, topic_id', 'from' => 'posts', 'where' => 'author_id=' . $this->memberData['member_id'] . ' AND topic_id IN(' . implode(',', $topic_ids) . ')'));
         $this->DB->execute();
         while ($p = $this->DB->fetch()) {
             if (is_array($topic_array[$p['topic_id']])) {
                 $topic_array[$p['topic_id']]['author_id'] = $p['author_id'];
             }
         }
     }
     //-----------------------------------------
     // Are we tracking watched stuff
     //-----------------------------------------
     if ($this->settings['cpu_watch_update'] == 1 and $this->memberData['member_id'] and count($topic_ids) and $parse_dots) {
         $this->DB->build(array('select' => 'topic_id, trid as trackingTopic', 'from' => 'tracker', 'where' => 'member_id=' . $this->memberData['member_id'] . ' AND topic_id IN(' . implode(',', $topic_ids) . ')'));
         $this->DB->execute();
         while ($p = $this->DB->fetch()) {
             if (is_array($topic_array[$p['topic_id']])) {
                 $topic_array[$p['topic_id']]['trackingTopic'] = 1;
             }
         }
     }
     //-----------------------------------------
     // Show meh the topics!
     //-----------------------------------------
     foreach ($topic_array as $topic) {
         if ($topic['pinned']) {
             $this->pinned_topic_count++;
         }
         $topic_data[$topic['tid']] = $this->renderEntry($topic);
         $total_topics_printed++;
     }
     //-----------------------------------------
     // Finish off the rest of the page  $filter_keys[$topicfilter]))
     //-----------------------------------------
     $sort_by_html = "";
     $sort_key_html = "";
     $prune_day_html = "";
     $filter_html = "";
     foreach ($sort_by_keys as $k => $v) {
         $sort_by_html .= $k == $sort_by ? "<option value='{$k}' selected='selected'>{$this->lang->words[$sort_by_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$sort_by_keys[$k]]}</option>\n";
     }
     foreach ($sort_keys as $k => $v) {
         $sort_key_html .= $k == $sort_key_chk ? "<option value='{$k}' selected='selected'>{$this->lang->words[$sort_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$sort_keys[$k]]}</option>\n";
     }
     foreach ($prune_by_day as $k => $v) {
         $prune_day_html .= $k == $prune_value ? "<option value='{$k}' selected='selected'>{$this->lang->words[$prune_by_day[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$prune_by_day[$k]]}</option>\n";
     }
     foreach ($filter_keys as $k => $v) {
         $filter_html .= $k == $topicfilter ? "<option value='{$k}' selected='selected'>{$this->lang->words[$filter_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$filter_keys[$k]]}</option>\n";
     }
     $footer_filter['sort_by'] = $sort_key_html;
     $footer_filter['sort_order'] = $sort_by_html;
     $footer_filter['sort_prune'] = $prune_day_html;
     $footer_filter['topic_filter'] = $filter_html;
     if ($this->memberData['is_mod']) {
         $count = 0;
         $other_pages = 0;
         if ($this->request['selectedtids'] != "") {
             $tids = explode(",", $this->request['selectedtids']);
             if (is_array($tids) and count($tids)) {
                 foreach ($tids as $tid) {
                     if ($tid != '') {
                         if (!isset($topic_array[$tid])) {
                             $other_pages++;
                         }
                         $count++;
                     }
                 }
             }
         }
         $this->lang->words['f_go'] .= " ({$count})";
         if ($other_pages) {
             $this->lang->words['f_go'] .= " ({$other_pages} " . $this->lang->words['jscript_otherpage'] . ")";
         }
     }
     //-----------------------------------------
     // Multi-moderation?
     //-----------------------------------------
     if ($this->memberData['is_mod']) {
         $mm_array = $this->registry->getClass('class_forums')->getMultimod($this->forum['id']);
         if (is_array($mm_array) and count($mm_array)) {
             foreach ($mm_array as $m) {
                 $multi_mod_data[] = $m;
             }
         }
     }
     //-----------------------------------------
     // Need to update topics?
     //-----------------------------------------
     if (count($this->update_topics_open)) {
         $this->DB->update('topics', array('state' => 'open'), 'tid IN (' . implode(",", $this->update_topics_open) . ')');
     }
     if (count($this->update_topics_close)) {
         $this->DB->update('topics', array('state' => 'closed'), 'tid IN (' . implode(",", $this->update_topics_close) . ')');
     }
     return array('announce_data' => $announce_data, 'topic_data' => $topic_data, 'other_data' => $other_data, 'multi_mod_data' => $multi_mod_data, 'footer_filter' => $footer_filter, 'active_users' => $this->settings['no_au_forum'] ? array('_done' => 0) : $this->_generateActiveUserData());
 }
Ejemplo n.º 11
0
 /**
  * Attempt to get a skin choice based on user-agent
  *
  * @access	private
  * @return	mixed		INT of a skin, FALSE if no skin found
  */
 private function _fetchSkinByUserAgent()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $useSkinID = FALSE;
     if ($this->memberData['userAgentKey'] and !$this->memberData['userAgentBypass']) {
         foreach ($this->allSkins as $id => $data) {
             /* Got perms? */
             if ($data['_youCanUse'] !== TRUE) {
                 continue;
             }
             /* Can use with this output format? */
             if ($data['_gatewayExclude'] !== FALSE) {
                 continue;
             }
             /* Check user agents first */
             if (is_array($data['_userAgents']['uagents'])) {
                 foreach ($data['_userAgents']['uagents'] as $_key => $_version) {
                     if ($this->memberData['userAgentKey'] == $_key) {
                         if ($_version) {
                             $_versions = explode(',', $_version);
                             foreach ($_versions as $_v) {
                                 if (strstr($_v, '+')) {
                                     if ($this->memberData['userAgentVersion'] >= intval($_v)) {
                                         $useSkinID = $id;
                                         break 3;
                                     }
                                 } else {
                                     if (strstr($_v, '-')) {
                                         if ($this->memberData['userAgentVersion'] <= intval($_v)) {
                                             $useSkinID = $id;
                                             break 3;
                                         }
                                     } else {
                                         if ($this->memberData['userAgentVersion'] == intval($_v)) {
                                             $useSkinID = $id;
                                             break 3;
                                         }
                                     }
                                 }
                             }
                         } else {
                             /* We don't care about versions.. */
                             $useSkinID = $id;
                             break 2;
                         }
                     }
                 }
             }
             /* Still here? */
             if (is_array($data['_userAgents']['groups']) and $useSkinID === FALSE) {
                 foreach ($data['_userAgents']['groups'] as $groupID) {
                     $_group = $this->caches['useragentgroups'][$groupID];
                     $_gData = unserialize($_group['ugroup_array']);
                     if (is_array($_gData)) {
                         foreach ($_gData as $__key => $__data) {
                             if ($this->memberData['userAgentKey'] == $__key) {
                                 if ($__data['uagent_versions']) {
                                     $_versions = explode(',', $__data['uagent_versions']);
                                     foreach ($_versions as $_v) {
                                         if (strstr($_v, '+')) {
                                             if ($this->memberData['userAgentVersion'] >= intval($_v)) {
                                                 $useSkinID = $id;
                                                 break 4;
                                             }
                                         } else {
                                             if (strstr($_v, '-')) {
                                                 if ($this->memberData['userAgentVersion'] <= intval($_v)) {
                                                     $useSkinID = $id;
                                                     break 4;
                                                 }
                                             } else {
                                                 if ($this->memberData['userAgentVersion'] == intval($_v)) {
                                                     $useSkinID = $id;
                                                     break 4;
                                                 }
                                             }
                                         }
                                     }
                                 } else {
                                     /* We don't care about versions.. */
                                     $useSkinID = $id;
                                     break 3;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     /* Did we automatically get set the mobile skin?
      * If so, assign cookie
      */
     if ($this->allSkins[$useSkinID]['set_key'] == 'mobile') {
         IPSCookie::set("mobileBrowser", 1, -1);
     }
     if ($useSkinID !== FALSE) {
         $this->memberData['userAgentLocked'] = TRUE;
         IPSDebug::addMessage("Skin set found via user agent. Using set #" . $useSkinID);
     }
     return $useSkinID;
 }
 /**
  * Topic set up ya'll
  *
  * @access	public
  * @return	void
  **/
 public function topicSetUp()
 {
     //-----------------------------------------
     // Memory...
     //-----------------------------------------
     $_before = IPSDebug::getMemoryDebugFlag();
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['start'] = !empty($this->request['start']) ? intval($this->request['start']) : '';
     $this->request['st'] = !empty($this->request['st']) ? intval($this->request['st']) : '';
     //-----------------------------------------
     // Compile the language file
     //-----------------------------------------
     $this->registry->class_localization->loadLanguageFile(array('public_boards', 'public_topic'));
     $this->registry->class_localization->loadLanguageFile(array('public_editors'), 'core');
     //-----------------------------------------
     // Get all the member groups and
     // member title info
     //-----------------------------------------
     if (!is_array($this->cache->getCache('ranks'))) {
         $this->cache->rebuildCache('ranks', 'global');
     }
     //-----------------------------------------
     // Are we actually a moderator for this forum?
     //-----------------------------------------
     if (!$this->memberData['g_is_supmod']) {
         $moderator = $this->memberData['forumsModeratorData'];
         if (!isset($moderator[$this->forum['id']]) or !is_array($moderator[$this->forum['id']])) {
             $this->memberData['is_mod'] = 0;
         }
     }
     $this->settings['_base_url'] = $this->settings['base_url'];
     $this->forum['FORUM_JUMP'] = $this->registry->getClass('class_forums')->buildForumJump();
     $this->first = intval($this->request['st']) > 0 ? intval($this->request['st']) : 0;
     $this->request['view'] = !empty($this->request['view']) ? $this->request['view'] : NULL;
     //-----------------------------------------
     // Check viewing permissions, private forums,
     // password forums, etc
     //-----------------------------------------
     if (!$this->memberData['g_other_topics'] and $this->topic['starter_id'] != $this->memberData['member_id']) {
         $this->registry->output->showError('topics_not_yours', 10359);
     } else {
         if (!$this->forum['can_view_others'] and !$this->memberData['is_mod'] and $this->topic['starter_id'] != $this->memberData['member_id']) {
             $this->registry->output->showError('topics_not_yours2', 10360);
         }
     }
     //-----------------------------------------
     // Update the topic views counter
     //-----------------------------------------
     if (!$this->request['view'] and $this->topic['state'] != 'link') {
         if ($this->settings['update_topic_views_immediately']) {
             $this->DB->update('topics', 'views=views+1', "tid=" . $this->topic['tid'], true, true);
         } else {
             $this->DB->insert('topic_views', array('views_tid' => $this->topic['tid']), true);
         }
     }
     //-----------------------------------------
     // Need to update this topic?
     //-----------------------------------------
     if ($this->topic['state'] == 'open') {
         if (!$this->topic['topic_open_time'] or $this->topic['topic_open_time'] < $this->topic['topic_close_time']) {
             if ($this->topic['topic_close_time'] and ($this->topic['topic_close_time'] <= time() and (time() >= $this->topic['topic_open_time'] or !$this->topic['topic_open_time']))) {
                 $this->topic['state'] = 'closed';
                 $this->DB->update('topics', array('state' => 'closed'), 'tid=' . $this->topic['tid'], true);
             }
         } else {
             if ($this->topic['topic_open_time'] or $this->topic['topic_open_time'] > $this->topic['topic_close_time']) {
                 if ($this->topic['topic_close_time'] and ($this->topic['topic_close_time'] <= time() and time() <= $this->topic['topic_open_time'])) {
                     $this->topic['state'] = 'closed';
                     $this->DB->update('topics', array('state' => 'closed'), 'tid=' . $this->topic['tid'], true);
                 }
             }
         }
     } else {
         if ($this->topic['state'] == 'closed') {
             if (!$this->topic['topic_close_time'] or $this->topic['topic_close_time'] < $this->topic['topic_open_time']) {
                 if ($this->topic['topic_open_time'] and ($this->topic['topic_open_time'] <= time() and (time() >= $this->topic['topic_close_time'] or !$this->topic['topic_close_time']))) {
                     $this->topic['state'] = 'open';
                     $this->DB->update('topics', array('state' => 'open'), 'tid=' . $this->topic['tid'], true);
                 }
             } else {
                 if ($this->topic['topic_close_time'] or $this->topic['topic_close_time'] > $this->topic['topic_open_time']) {
                     if ($this->topic['topic_open_time'] and ($this->topic['topic_open_time'] <= time() and time() <= $this->topic['topic_close_time'])) {
                         $this->topic['state'] = 'open';
                         $this->DB->update('topics', array('state' => 'open'), 'tid=' . $this->topic['tid'], true);
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Current topic rating value
     //-----------------------------------------
     $this->topic['_rate_show'] = 0;
     $this->topic['_rate_int'] = 0;
     $this->topic['_rate_img'] = '';
     if ($this->topic['state'] != 'open') {
         $this->topic['_allow_rate'] = 0;
     } else {
         $this->topic['_allow_rate'] = $this->can_rate;
     }
     if ($this->forum['forum_allow_rating']) {
         $rating = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'topic_ratings', 'where' => "rating_tid={$this->topic['tid']} and rating_member_id=" . $this->memberData['member_id']));
         if ($rating['rating_value'] and $this->memberData['g_topic_rate_setting'] != 2) {
             $this->topic['_allow_rate'] = 0;
         }
         $this->topic['_rate_id'] = 0;
         $this->topic['_rating_value'] = $rating['rating_value'] ? $rating['rating_value'] : -1;
         if ($this->topic['topic_rating_total']) {
             $this->topic['_rate_int'] = round($this->topic['topic_rating_total'] / $this->topic['topic_rating_hits']);
         }
         //-----------------------------------------
         // Show image?
         //-----------------------------------------
         if ($this->topic['topic_rating_hits'] >= $this->settings['topic_rating_needed'] and $this->topic['_rate_int']) {
             $this->topic['_rate_id'] = $this->topic['_rate_int'];
             $this->topic['_rate_show'] = 1;
         }
     } else {
         $this->topic['_allow_rate'] = 0;
     }
     //-----------------------------------------
     // Update the item marker
     //-----------------------------------------
     if (!$this->request['view']) {
         $this->registry->getClass('classItemMarking')->markRead(array('forumID' => $this->forum['id'], 'itemID' => $this->topic['tid']));
     }
     //-----------------------------------------
     // If this forum is a link, then
     // redirect them to the new location
     //-----------------------------------------
     if ($this->topic['state'] == 'link') {
         $f_stuff = explode("&", $this->topic['moved_to']);
         $this->registry->output->redirectScreen($this->lang->words['topic_moved'], $this->settings['base_url'] . "showtopic={$f_stuff[0]}");
     }
     //-----------------------------------------
     // If this is a sub forum, we need to get
     // the cat details, and parent details
     //-----------------------------------------
     $this->nav = $this->registry->class_forums->forumsBreadcrumbNav($this->forum['id']);
     //-----------------------------------------
     // Are we a moderator?
     //-----------------------------------------
     if ($this->memberData['member_id'] and $this->memberData['g_is_supmod'] != 1) {
         $other_mgroups = array();
         if ($this->memberData['mgroup_others']) {
             $other_mgroups = explode(",", IPSText::cleanPermString($this->memberData['mgroup_others']));
         }
         $other_mgroups[] = $this->memberData['member_group_id'];
         $member_group_ids = implode(",", $other_mgroups);
         $this->moderator = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'moderators', 'where' => "forum_id LIKE '%,{$this->forum['id']},%' AND (member_id={$this->memberData['member_id']} OR (is_group=1 AND group_id IN({$member_group_ids})))"));
     }
     //-----------------------------------------
     // Hi! Light?
     //-----------------------------------------
     $hl = (isset($this->request['hl']) and $this->request['hl']) ? '&amp;hl=' . $this->request['hl'] : '';
     //-----------------------------------------
     // If we can see queued topics, add count
     //-----------------------------------------
     if ($this->registry->class_forums->canQueuePosts($this->forum['id'])) {
         if (isset($this->request['modfilter']) and $this->request['modfilter'] == 'invisible_posts') {
             $this->topic['posts'] = intval($this->topic['topic_queuedposts']);
         } else {
             $this->topic['posts'] += intval($this->topic['topic_queuedposts']);
         }
     }
     //-----------------------------------------
     // Generate the forum page span links
     //-----------------------------------------
     $this->topic['SHOW_PAGES'] = $this->registry->output->generatePagination(array('totalItems' => $this->topic['posts'] + 1, 'itemsPerPage' => $this->settings['display_max_posts'], 'currentStartValue' => $this->first, 'seoTitle' => $this->topic['title_seo'], 'seoTemplate' => 'showtopic', 'baseUrl' => "showtopic=" . $this->topic['tid'] . $hl));
     if ($this->topic['posts'] + 1 > $this->settings['display_max_posts']) {
         //	$this->topic['go_new'] = $this->registry->output->getTemplate('topic')->golastpost_link($this->forum['id'], $this->topic['tid'] );
     }
     //-----------------------------------------
     // Fix up some of the words
     //-----------------------------------------
     $this->topic['TOPIC_START_DATE'] = $this->registry->class_localization->getDate($this->topic['start_date'], 'LONG');
     $this->lang->words['topic_stats'] = str_replace("<#START#>", $this->topic['TOPIC_START_DATE'], $this->lang->words['topic_stats']);
     $this->lang->words['topic_stats'] = str_replace("<#POSTS#>", $this->topic['posts'], $this->lang->words['topic_stats']);
     //-----------------------------------------
     // Multi Quoting?
     //-----------------------------------------
     $this->qpids = IPSCookie::get('mqtids');
     //-----------------------------------------
     // Multi PIDS?
     //-----------------------------------------
     $this->request['selectedpids'] = !empty($this->request['selectedpids']) ? $this->request['selectedpids'] : IPSCookie::get('modpids');
     $this->request['selectedpidcount'] = 0;
     IPSCookie::set('modpids', '', 0);
     IPSDebug::setMemoryDebugFlag("TOPIC: topics.php::topicSetUp", $_before);
 }
Ejemplo n.º 13
0
 /**
  * Action: Log in as member
  */
 protected function _loginAsMember()
 {
     $memberID = intval($this->request['member_id']);
     //-----------------------------------------
     // Load member
     //-----------------------------------------
     $member = IPSMember::load($memberID, 'all');
     if (!$member['member_id']) {
         return $this->_memberView();
     }
     if ($member['g_access_cp']) {
         $this->registry->getClass('class_permissions')->checkPermissionAutoMsg('member_edit_admin');
     }
     //-----------------------------------------
     // 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 ($this->settings['login_change_key'] or !$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 ($setCookies) {
         IPSCookie::set("member_id", $member['member_id'], 1);
         IPSCookie::set("pass_hash", $member['member_login_key'], $_sticky, $_days);
     } else {
         IPSCookie::set("member_id", $member['member_id'], 0);
         IPSCookie::set("pass_hash", $member['member_login_key'], 0);
     }
     //-----------------------------------------
     // Create / Update session
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/session/publicSessions.php', 'publicSessions');
     $sessionClass = new $classToLoad();
     $session_id = $sessionClass->convertGuestToMember(array('member_name' => $member['members_display_name'], 'member_id' => $member['member_id'], 'member_group' => $member['member_group_id'], 'login_type' => 0));
     //-----------------------------------------
     // Boink
     //-----------------------------------------
     $this->registry->output->silentRedirect($this->settings['board_url']);
 }
 /**
  * Log a user out
  *
  * @access	public
  * @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");
     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'] . 'ipbforumpass') !== false) {
                 IPSCookie::set($cookie, '-', -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())));
     //-----------------------------------------
     // 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['base_url']);
 }
 /**
  * Unset cookies
  *
  * @access	public
  * @return	void
  */
 public function unsetCookies()
 {
     foreach (array('_user', '_session_key', '_expires', '_ss') as $key) {
         IPSCookie::set($this->settings['fbc_api_id'] . $key, -1, 0, -1);
         unset($_COOKIE[$this->settings['fbc_api_id'] . $key]);
     }
     IPSCookie::set($this->settings['fbc_api_id'], -1, 0, -1);
     IPSCookie::set('fbsetting_' . $this->settings['fbc_api_id'], -1, 0, -1);
 }
Ejemplo n.º 16
0
 /**
  * Init method
  *
  * @param	mixed	Extra data (can be used by extending classes)
  * @return	@e void
  */
 public function init($extraData = null)
 {
     $this->lang->loadLanguageFile(array('public_topic'), 'forums');
     /* Init some data */
     $this->_settings = $this->settings();
     $this->qpids = IPSCookie::get('comment_pids');
     $this->request['selectedpids'] = IPSCookie::get('commentmodpids');
     $this->request['selectedpidcount'] = intval(count(preg_split("/,/", $this->request['commentmodpids'], -1, PREG_SPLIT_NO_EMPTY)));
     IPSCookie::set('commentmodpids', '', 0);
     /* Load parser */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
     $this->parser = new $classToLoad();
     /* set up parser */
     $this->parser->set(array('memberData' => $this->memberData, 'parseBBCode' => 1, 'parseHtml' => 0, 'parseEmoticons' => 1, 'parseArea' => 'comments'));
 }
 /**
  * Show the reply form
  *
  * @access	protected
  * @param	string	Type of form (new/reply/add)
  * @param 	array	Array of extra data
  * @return 	void 	[Passes data to classOutput]
  */
 protected function _displayForm($formType, $extraData = array())
 {
     //-----------------------------------------
     // Set up
     //-----------------------------------------
     $output = '';
     $titleText = '';
     $buttonText = '';
     $doCode = '';
     $topText = '';
     $checkFunc = '';
     //-----------------------------------------
     // Work out function type
     //-----------------------------------------
     switch ($formType) {
         default:
         case 'reply':
             $checkFunc = 'replySetUp';
             break;
         case 'new':
             $checkFunc = 'topicSetUp';
             break;
         case 'edit':
             $checkFunc = 'editSetUp';
             break;
     }
     //-----------------------------------------
     // Global checks and functions
     //-----------------------------------------
     try {
         $this->globalSetUp();
     } catch (Exception $error) {
         throw new Exception($error->getMessage());
     }
     //-----------------------------------------
     // Form specific...
     //-----------------------------------------
     try {
         $topic = $this->{$checkFunc}();
     } catch (Exception $error) {
         throw new Exception($error->getMessage());
     }
     //-----------------------------------------
     // Work out elements
     //-----------------------------------------
     switch ($formType) {
         default:
         case 'reply':
             $doCode = 'reply_post_do';
             $titleText = $this->lang->words['top_txt_reply'] . ' ' . $topic['title'];
             $buttonText = $this->lang->words['submit_reply'];
             $topText = $this->lang->words['replying_in'] . ' ' . $topic['title'];
             break;
         case 'new':
             $doCode = 'new_post_do';
             $titleText = $this->lang->words['top_txt_new'] . $this->getForumData('name');
             $buttonText = $this->lang->words['submit_new'];
             $topText = $this->lang->words['posting_new_topic'];
             break;
         case 'edit':
             $doCode = 'edit_post_do';
             $titleText = $this->lang->words['top_txt_edit'] . ' ' . $topic['title'];
             $buttonText = $this->lang->words['submit_edit'];
             $topText = $this->lang->words['editing_post'] . ' ' . $topic['title'];
             /* Reset reason for edit */
             $extraData['reasonForEdit'] = $this->request['post_edit_reason'] ? $this->request['post_edit_reason'] : $this->_originalPost['post_edit_reason'];
             /* Reset check boxes and such */
             $this->setSettings(array('enableSignature' => $this->_originalPost['use_sig'], 'enableEmoticons' => $this->_originalPost['use_emo'], 'post_htmlstatus' => $this->_originalPost['post_htmlstate'], 'enableTracker' => (intval($this->request['enabletrack']) != 0 or $this->getIsPreview() !== TRUE) ? 1 : 0));
             break;
     }
     //-----------------------------------------
     // Parse the post, and check for any errors.
     //-----------------------------------------
     $post = $this->compilePostData();
     $postContent = $this->getPostContentPreFormatted() ? $this->getPostContentPreFormatted() : $this->getPostContent();
     //-----------------------------------------
     // Hmmmmm....
     //-----------------------------------------
     $postContent = $this->_afterPostCompile($postContent, $formType);
     //-----------------------------------------
     // Compile the poll
     //-----------------------------------------
     $this->poll_questions = $this->compilePollData();
     //-----------------------------------------
     // Are we quoting posts?
     //-----------------------------------------
     $postContent = $this->_checkMultiQuote($postContent);
     //-----------------------------------------
     // RTE? Convert RIGHT tags that QUOTE would
     // have put there
     // Commented out 14/7/08 - _afterPostCompile handles this for edit, and should
     // 	also handle for any other type if they need it...
     //-----------------------------------------
     /*if ( IPSText::getTextClass('editor')->method == 'rte' )
     		{
     			$postContent = IPSText::getTextClass('bbcode')->convertForRTE( $postContent );
     		}*/
     //-----------------------------------------
     // Do we have any posting errors?
     //-----------------------------------------
     if ($this->_postErrors) {
         $output .= $this->registry->getClass('output')->getTemplate('post')->errors($this->lang->words[$this->_postErrors]);
     }
     if ($this->getIsPreview()) {
         $output .= $this->registry->getClass('output')->getTemplate('post')->preview($this->_generatePostPreview($this->getPostContentPreFormatted() ? $this->getPostContentPreFormatted() : $this->getPostContent(), $this->post_key));
     }
     /* Defaults */
     if (!isset($extraData['checked'])) {
         $extraData['checked'] = '';
     }
     //-----------------------------------------
     // Gather status messages
     //-----------------------------------------
     /* status from mod posts */
     $this->registry->getClass('class_forums')->checkGroupPostPerDay($this->getAuthor(), TRUE);
     $_statusMsg[] = $this->registry->getClass('class_forums')->ppdStatusMessage;
     $_statusMsg[] = $this->registry->getClass('class_forums')->fetchPostModerationStatusMessage($this->getAuthor(), $this->getForumData(), $topic, $formType);
     //-----------------------------------------
     // Load attachments so we get some stats
     //-----------------------------------------
     require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php';
     $class_attach = new class_attach($this->registry);
     $class_attach->type = 'post';
     $class_attach->attach_post_key = $this->post_key;
     $class_attach->init();
     $class_attach->getUploadFormSettings();
     //-----------------------------------------
     // START TABLE
     //-----------------------------------------
     $output .= $this->registry->getClass('output')->getTemplate('post')->postFormTemplate(array('title' => $titleText, 'captchaHTML' => $this->_generateGuestCaptchaHTML(), 'checkBoxes' => $this->_generateCheckBoxes($formType, isset($topic['tid']) ? $topic['tid'] : 0, $this->getForumData('id')), 'editor' => IPSText::getTextClass('editor')->showEditor($postContent, 'Post'), 'buttonText' => $buttonText, 'uploadForm' => $this->can_upload ? $this->registry->getClass('output')->getTemplate('post')->uploadForm($this->post_key, 'post', $class_attach->attach_stats, $this->getPostID(), $this->getForumData('id')) : "", 'postIconSelected' => $this->_generatePostIcons(), 'topicSummary' => $this->_generateTopicSummary($topic['tid']), 'formType' => $formType, 'extraData' => $extraData, 'modOptionsData' => $this->_generateModOptions($topic, $formType), 'pollBoxHTML' => $this->_generatePollBox($formType), 'canEditTitle' => $this->edit_title, 'topicTitle' => $this->_topicTitle ? $this->_topicTitle : $topic['title'], 'topicDesc' => $this->_topicDescription ? $this->_topicDescription : $topic['description'], 'seoTopic' => $topic['title_seo'], 'seoForum' => $this->getForumData('name_seo'), 'statusMsg' => $_statusMsg), array('doCode' => $doCode, 'p' => $this->getPostID(), 't' => $topic['tid'], 'f' => $this->getForumData('id'), 'parent' => ipsRegistry::$request['parent_id'] ? intval(ipsRegistry::$request['parent_id']) : 0, 'attach_post_key' => $this->post_key));
     //-----------------------------------------
     // Reset multi-quote cookie
     //-----------------------------------------
     IPSCookie::set('mqtids', ',', 0);
     //-----------------------------------------
     // Send for output
     //-----------------------------------------
     $this->registry->getClass('output')->setTitle($topText . ' - ' . $this->settings['board_name']);
     $this->registry->getClass('output')->addContent($output);
     $this->nav = $this->registry->getClass('class_forums')->forumsBreadcrumbNav($this->getForumData('id'));
     if (isset($topic['tid']) and $topic['tid']) {
         $this->nav[] = array($topic['title'], "showtopic={$topic['tid']}", $topic['title_seo'], 'showtopic');
     }
     if (is_array($this->nav) and count($this->nav)) {
         foreach ($this->nav as $_nav) {
             $this->registry->getClass('output')->addNavigation($_nav[0], $_nav[1], $_nav[2], $_nav[3]);
         }
     }
     $this->registry->getClass('output')->sendOutput();
 }
Ejemplo n.º 18
0
 /**
  * Show the reply form
  *
  * @param	string	Type of form (new/reply/add)
  * @param 	array	Array of extra data
  * @return 	void 	[Passes data to classOutput]
  */
 protected function _displayForm($formType, $extraData = array())
 {
     //-----------------------------------------
     // Set up
     //-----------------------------------------
     $output = '';
     $titleText = '';
     $buttonText = '';
     $doCode = '';
     $topText = '';
     $checkFunc = '';
     $autoSaveKey = '';
     //-----------------------------------------
     // Work out function type
     //-----------------------------------------
     switch ($formType) {
         default:
         case 'reply':
             $checkFunc = 'replySetUp';
             break;
         case 'new':
             $checkFunc = 'topicSetUp';
             break;
         case 'edit':
             $checkFunc = 'editSetUp';
             break;
     }
     //-----------------------------------------
     // Global checks and functions
     //-----------------------------------------
     try {
         $this->globalSetUp();
     } catch (Exception $error) {
         $e = $error->getMessage();
         if ($formType == 'edit' and $e == 'NO_POSTING_PPD') {
         } else {
             throw new Exception($e);
         }
     }
     //-----------------------------------------
     // Form specific...
     //-----------------------------------------
     try {
         $topic = $this->{$checkFunc}();
     } catch (Exception $error) {
         throw new Exception($error->getMessage());
     }
     //-----------------------------------------
     // Work out elements
     //-----------------------------------------
     switch ($formType) {
         default:
         case 'reply':
             $doCode = 'reply_post_do';
             $titleText = $this->lang->words['top_txt_reply'] . ' ' . $topic['title'];
             $buttonText = $this->lang->words['submit_reply'];
             $topText = $this->lang->words['replying_in'] . ' ' . $topic['title'];
             $autoSaveKey = 'reply-' . intval($this->request['t']);
             break;
         case 'new':
             $doCode = 'new_post_do';
             $titleText = $this->lang->words['top_txt_new'] . $this->getForumData('name');
             $buttonText = $this->lang->words['submit_new'];
             $topText = $this->lang->words['posting_new_topic'];
             $autoSaveKey = 'new-' . intval($this->request['f']);
             $tagBox = '';
             $where = array('meta_parent_id' => intval($this->request['f']), 'member_id' => $this->memberData['member_id'], 'existing_tags' => explode(',', IPSText::cleanPermString($_REQUEST['ipsTags'])));
             if ($this->registry->tags->can('add', $where)) {
                 $tagBox = $this->registry->tags->render('entryBox', $where);
             }
             break;
         case 'edit':
             $doCode = 'edit_post_do';
             $titleText = $this->lang->words['top_txt_edit'] . ' ' . $topic['title'];
             $buttonText = $this->lang->words['submit_edit'];
             $topText = $this->lang->words['editing_post'] . ' ' . $topic['title'];
             $autoSaveKey = 'edit-' . intval($this->request['p']);
             $where = array('meta_id' => $topic['tid'], 'meta_parent_id' => intval($this->request['f']), 'member_id' => $this->memberData['member_id']);
             if ($_REQUEST['ipsTags']) {
                 $where['existing_tags'] = explode(',', IPSText::cleanPermString($_REQUEST['ipsTags']));
             }
             if ($this->registry->tags->can('edit', $where) && $this->request['p'] == $topic['topic_firstpost']) {
                 $tagBox = $this->registry->tags->render('entryBox', $where);
             }
             /* Are we following? */
             require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php';
             /*noLibHook*/
             $_like = classes_like::bootstrap('forums', 'topics');
             $_likes = $_like->isLiked($this->getTopicData('tid'), $this->getAuthor('member_id'));
             //-----------------------------------------
             // Appending a reason for the edit?
             //-----------------------------------------
             $extraData['showAppendEdit'] = 0;
             if ($this->getAuthor('g_append_edit')) {
                 $extraData['showEditOptions'] = 1;
                 $extraData['showAppendEdit'] = 1;
                 if ($this->_originalPost['append_edit']) {
                     $extraData['checked'] = 'checked';
                 } else {
                     $extraData['checked'] = '';
                 }
             }
             if (isset($this->moderator['edit_post']) && $this->moderator['edit_post'] or $this->getAuthor('g_is_supmod')) {
                 $extraData['showEditOptions'] = 1;
                 $extraData['showReason'] = 1;
             }
             /* Reset reason for edit */
             $extraData['reasonForEdit'] = $this->request['post_edit_reason'] ? $this->request['post_edit_reason'] : $this->_originalPost['post_edit_reason'];
             $extraData['append_edit'] = $this->request['append_edit'] ? $this->request['append_edit'] : $this->_originalPost['append_edit'];
             /* Reset check boxes and such */
             $this->setSettings(array('enableSignature' => $this->_originalPost['use_sig'], 'enableEmoticons' => $this->_originalPost['use_emo'], 'post_htmlstatus' => $this->_originalPost['post_htmlstate'], 'enableTracker' => intval($this->request['enabletrack']) != 0 ? 1 : ($_likes ? 1 : 0)));
             break;
     }
     //-----------------------------------------
     // Parse the post, and check for any errors.
     //-----------------------------------------
     $post = $this->compilePostData();
     $postContent = $this->getPostContentPreFormatted() ? $this->getPostContentPreFormatted() : $this->getPostContent();
     //-----------------------------------------
     // Hmmmmm....
     //-----------------------------------------
     $postContent = $this->_afterPostCompile($postContent, $formType);
     //-----------------------------------------
     // Compile the poll
     //-----------------------------------------
     $this->poll_questions = $this->compilePollData();
     //-----------------------------------------
     // Are we quoting posts?
     //-----------------------------------------
     $postContent = $this->_checkMultiQuote($postContent);
     /* Set HTML status */
     if ($this->_canHtml($this->getForumData('id')) && $this->_originalPost['post_htmlstate']) {
         $this->editor->setIsHtml(true);
     }
     /* Set content in editor */
     $this->editor->setContent($postContent);
     //-----------------------------------------
     // Do we have any posting errors?
     //-----------------------------------------
     if ($this->_postErrors) {
         $output .= $this->registry->getClass('output')->getTemplate('post')->errors(isset($this->lang->words[$this->_postErrors]) ? $this->lang->words[$this->_postErrors] : $this->_postErrors);
     }
     if ($this->getIsPreview()) {
         $output .= $this->registry->getClass('output')->getTemplate('post')->preview($this->_generatePostPreview($this->getPostContentPreFormatted() ? $this->getPostContentPreFormatted() : $this->getPostContent(), $this->post_key));
     }
     /* Defaults */
     if (!isset($extraData['checked'])) {
         $extraData['checked'] = '';
     }
     //-----------------------------------------
     // Gather status messages
     //-----------------------------------------
     /* status from mod posts */
     $this->registry->getClass('class_forums')->checkGroupPostPerDay($this->getAuthor(), TRUE);
     if ($formType != 'edit' and $this->registry->getClass('class_forums')->ppdStatusMessage) {
         $_statusMsg[] = $this->registry->getClass('class_forums')->ppdStatusMessage;
     }
     $modAll = FALSE;
     switch (intval($this->getForumData('preview_posts'))) {
         case 1:
             $modAll = TRUE;
             break;
         case 2:
             if ($formType == 'new') {
                 $modAll = TRUE;
             }
             break;
         case 3:
             if ($formType == 'reply') {
                 $modAll = TRUE;
             }
             break;
     }
     //-----------------------------------------
     // Load attachments so we get some stats
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php', 'class_attach');
     $class_attach = new $classToLoad($this->registry);
     $class_attach->type = 'post';
     $class_attach->attach_post_key = $this->post_key;
     $class_attach->init();
     $class_attach->getUploadFormSettings();
     //-----------------------------------------
     // START TABLE
     //-----------------------------------------
     $output .= $this->registry->getClass('output')->getTemplate('post')->postFormTemplate(array('title' => $titleText, 'captchaHTML' => $this->_generateGuestCaptchaHTML(), 'checkBoxes' => $this->_generateCheckBoxes($formType, isset($topic['tid']) ? $topic['tid'] : 0, $this->getForumData('id')), 'editor' => $this->editor->show('Post', array('autoSaveKey' => $autoSaveKey, 'height' => 350, 'warnInfo' => 'full', 'modAll' => $modAll)), 'buttonText' => $buttonText, 'uploadForm' => $this->can_upload ? $this->registry->getClass('output')->getTemplate('post')->uploadForm($this->post_key, 'post', $class_attach->attach_stats, $this->getPostID(), $this->getForumData('id')) : "", 'topicSummary' => $this->_generateTopicSummary($topic['tid']), 'formType' => $formType, 'extraData' => $extraData, 'modOptionsData' => $this->_generateModOptions($topic, $formType), 'pollBoxHTML' => $this->_generatePollBox($formType), 'canEditTitle' => $this->edit_title, 'topicTitle' => $this->_topicTitle ? $this->_topicTitle : $topic['title'], 'seoTopic' => $topic['title_seo'], 'seoForum' => $this->getForumData('name_seo'), 'statusMsg' => $_statusMsg, 'tagBox' => $tagBox, 'socialShareOff' => $formType != 'new' ? 1 : $this->getForumData('disable_sharelinks')), array('doCode' => $doCode, 'p' => $this->getPostID(), 't' => $topic['tid'], 'f' => $this->getForumData('id'), 'parent' => ipsRegistry::$request['parent_id'] ? intval(ipsRegistry::$request['parent_id']) : 0, 'attach_post_key' => $this->post_key));
     //-----------------------------------------
     // Reset multi-quote cookie
     //-----------------------------------------
     IPSCookie::set('mqtids', ',', 0);
     //-----------------------------------------
     // Send for output
     //-----------------------------------------
     $this->registry->getClass('output')->setTitle($topText . ' - ' . $this->settings['board_name']);
     $this->registry->getClass('output')->addContent($output);
     $this->nav = $this->registry->getClass('class_forums')->forumsBreadcrumbNav($this->getForumData('id'));
     if (!empty($topic['tid'])) {
         $this->nav[] = array($topic['title'], "showtopic={$topic['tid']}", $topic['title_seo'], 'showtopic');
     }
     if (is_array($this->nav) and count($this->nav)) {
         foreach ($this->nav as $_nav) {
             $this->registry->getClass('output')->addNavigation($_nav[0], $_nav[1], $_nav[2], $_nav[3]);
         }
     }
     $this->registry->getClass('output')->sendOutput();
 }
Ejemplo n.º 19
0
 /**
  * Processes the registration form
  *
  * @return	@e void
  */
 public function registerProcessForm()
 {
     $this->_resetMember();
     $form_errors = array();
     $coppa = $this->request['coppa_user'] == 1 ? 1 : 0;
     $in_password = trim($this->request['PassWord']);
     $in_email = strtolower(trim($this->request['EmailAddress']));
     /* Did we agree to the t&c? */
     if (!$this->request['agree_tos']) {
         $form_errors['tos'] = array($this->lang->words['must_agree_to_terms']);
     }
     /* Custom profile field stuff */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields');
     $custom_fields = new $classToLoad();
     $custom_fields->initData('edit');
     $custom_fields->parseToSave($_POST, 'register');
     /* Check */
     if ($custom_fields->error_messages) {
         $form_errors['general'] = $custom_fields->error_messages;
     }
     /* Check the email address */
     if (!$in_email or strlen($in_email) < 6 or !IPSText::checkEmailAddress($in_email)) {
         $form_errors['email'][$this->lang->words['err_invalid_email']] = $this->lang->words['err_invalid_email'];
     }
     if (trim($this->request['PassWord_Check']) != $in_password or !$in_password) {
         $form_errors['password'][$this->lang->words['passwords_not_match']] = $this->lang->words['passwords_not_match'];
     }
     /*
     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
     elseif ( strlen( $in_password ) < 3 )
     {
     	$form_errors['password'][$this->lang->words['pass_too_short']] = $this->lang->words['pass_too_short'];
     }
     elseif ( strlen( $in_password ) > 32 )
     {
     	$form_errors['password'][$this->lang->words['pass_too_long']] = $this->lang->words['pass_too_long'];
     }
     */
     /* Check the username */
     $user_check = IPSMember::getFunction()->cleanAndCheckName($this->request['members_display_name'], array(), 'name');
     $disp_check = IPSMember::getFunction()->cleanAndCheckName($this->request['members_display_name'], array(), 'members_display_name');
     if (is_array($user_check['errors']) && count($user_check['errors'])) {
         foreach ($user_check['errors'] as $key => $error) {
             $form_errors['dname'][$error] = isset($this->lang->words[$error]) ? $this->lang->words[$error] : $error;
         }
     }
     /* this duplicates username error above */
     /*if( is_array( $disp_check['errors'] ) && count( $disp_check['errors'] ) )
     		{
     			foreach( $disp_check['errors'] as $key => $error )
     			{
     				$form_errors['dname'][ $error ]	= isset($this->lang->words[ $error ]) ? $this->lang->words[ $error ] : $error;
     			}
     		}*/
     /* Is this email addy taken? */
     if (IPSMember::checkByEmail($in_email) == TRUE) {
         $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken'];
     }
     /* 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->emailExistsCheck($in_email);
     if ($this->han_login->return_code and $this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'EMAIL_NOT_IN_USE') {
         $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken'];
     }
     /* Are they banned [EMAIL]? */
     if (IPSMember::isBanned('email', $in_email) === TRUE) {
         $form_errors['email'][$this->lang->words['reg_error_email_ban']] = $this->lang->words['reg_error_email_ban'];
     }
     /* Check the CAPTCHA */
     if ($this->settings['bot_antispam_type'] != 'none') {
         if ($this->registry->getClass('class_captcha')->validate() !== TRUE) {
             $form_errors['general'][$this->lang->words['err_reg_code']] = $this->lang->words['err_reg_code'];
         }
     }
     /* Check the Q and A */
     $qanda = intval($this->request['qanda_id']);
     $pass = true;
     if ($qanda) {
         $pass = false;
         $data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'question_and_answer', 'where' => 'qa_id=' . $qanda));
         if ($data['qa_id']) {
             $answers = explode("\n", str_replace("\r", "", $data['qa_answers']));
             if (count($answers)) {
                 foreach ($answers as $answer) {
                     $answer = trim($answer);
                     if (IPSText::mbstrlen($answer) and mb_strtolower($answer) == mb_strtolower($this->request['qa_answer'])) {
                         $pass = true;
                         break;
                     }
                 }
             }
         }
     } else {
         //-----------------------------------------
         // Do we have any questions?
         //-----------------------------------------
         $data = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as questions', 'from' => 'question_and_answer'));
         if ($data['questions']) {
             $pass = false;
         }
     }
     if (!$pass) {
         $form_errors['general'][$this->lang->words['err_q_and_a']] = $this->lang->words['err_q_and_a'];
     }
     /* CHECK 2: Any errors ? */
     if (count($form_errors)) {
         $this->registerForm($form_errors);
         return;
     }
     /* Build up the hashes */
     $mem_group = $this->settings['member_group'];
     /* Are we asking the member or admin to preview? */
     if ($this->settings['reg_auth_type']) {
         $mem_group = $this->settings['auth_group'];
     } else {
         if ($coppa == 1) {
             $mem_group = $this->settings['auth_group'];
         }
     }
     /* Create member */
     $member = array('name' => $this->request['members_display_name'], 'password' => $in_password, 'members_display_name' => $this->request['members_display_name'], 'email' => $in_email, 'member_group_id' => $mem_group, 'joined' => time(), 'ip_address' => $this->member->ip_address, 'time_offset' => $this->request['time_offset'], 'coppa_user' => $coppa, 'members_auto_dst' => intval($this->settings['time_dst_auto_correction']), 'allow_admin_mails' => intval($this->request['allow_admin_mail']), 'language' => $this->member->language_id);
     /* Spam Service */
     $spamCode = 0;
     $_spamFlag = 0;
     if ($this->settings['spam_service_enabled']) {
         /* Query the service */
         $spamCode = IPSMember::querySpamService($in_email);
         /* Action to perform */
         $action = $this->settings['spam_service_action_' . $spamCode];
         /* Perform Action */
         switch ($action) {
             /* Proceed with registration */
             case 1:
                 break;
                 /* Flag for admin approval */
             /* Flag for admin approval */
             case 2:
                 $member['member_group_id'] = $this->settings['auth_group'];
                 $this->settings['reg_auth_type'] = 'admin';
                 $_spamFlag = 1;
                 break;
                 /* Approve the account, but ban it */
             /* Approve the account, but ban it */
             case 3:
                 $member['member_banned'] = 1;
                 $member['bw_is_spammer'] = 1;
                 $this->settings['reg_auth_type'] = '';
                 break;
                 /* Deny registration */
             /* Deny registration */
             case 4:
                 $this->registry->output->showError('spam_denied_account', '100x001', FALSE, '', 200);
                 break;
         }
     }
     //-----------------------------------------
     // Create the account
     //-----------------------------------------
     $member = IPSMember::create(array('members' => $member, 'pfields_content' => $custom_fields->out_fields), FALSE, FALSE, FALSE);
     //-----------------------------------------
     // Login handler create account callback
     //-----------------------------------------
     $this->han_login->createAccount(array('member_id' => $member['member_id'], 'email' => $member['email'], 'joined' => $member['joined'], 'password' => $in_password, 'ip_address' => $this->member->ip_address, 'username' => $member['members_display_name'], 'name' => $member['name'], 'members_display_name' => $member['members_display_name']));
     //-----------------------------------------
     // We'll just ignore if this fails - it shouldn't hold up IPB anyways
     //-----------------------------------------
     /*if ( $han_login->return_code AND ( $han_login->return_code != 'METHOD_NOT_DEFINED' AND $han_login->return_code != 'SUCCESS' ) )
     		{
     			$this->registry->output->showError( 'han_login_create_failed', 2017, true );
     		}*/
     //-----------------------------------------
     // Validation
     //-----------------------------------------
     $validate_key = md5(IPSMember::makePassword() . time());
     $time = time();
     if ($coppa != 1) {
         if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin' or $this->settings['reg_auth_type'] == 'admin_user') {
             //-----------------------------------------
             // We want to validate all reg's via email,
             // after email verificiation has taken place,
             // we restore their previous group and remove the validate_key
             //-----------------------------------------
             $this->DB->insert('validating', array('vid' => $validate_key, 'member_id' => $member['member_id'], 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => $time, 'coppa_user' => $coppa, 'new_reg' => 1, 'ip_address' => $member['ip_address'], 'spam_flag' => $_spamFlag));
             if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin_user') {
                 /* Send out the email. */
                 $message = array('THE_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global&section=register&do=auto_validate&uid=" . urlencode($member['member_id']) . "&aid=" . urlencode($validate_key), 'publicNoSession', 'false'), 'NAME' => $member['members_display_name'], 'MAN_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global&section=register&do=05", 'publicNoSession', 'false'), 'EMAIL' => $member['email'], 'ID' => $member['member_id'], 'CODE' => $validate_key);
                 IPSText::getTextClass('email')->setPlainTextTemplate(IPSText::getTextClass('email')->getTemplate("reg_validate", $this->member->language_id));
                 IPSText::getTextClass('email')->buildPlainTextContent($message);
                 IPSText::getTextClass('email')->buildHtmlContent($message);
                 IPSText::getTextClass('email')->subject = sprintf($this->lang->words['new_registration_email'], $this->settings['board_name']);
                 IPSText::getTextClass('email')->to = $member['email'];
                 IPSText::getTextClass('email')->sendMail();
                 $this->output = $this->registry->output->getTemplate('register')->showAuthorize($member);
             } else {
                 if ($this->settings['reg_auth_type'] == 'admin') {
                     $this->output = $this->registry->output->getTemplate('register')->showPreview($member);
                 }
             }
             /* Only send new registration email if the member wasn't banned */
             if ($this->settings['new_reg_notify'] and !$member['member_banned']) {
                 $date = $this->registry->class_localization->getDate(time(), 'LONG', 1);
                 IPSText::getTextClass('email')->getTemplate('admin_newuser');
                 IPSText::getTextClass('email')->buildMessage(array('DATE' => $date, 'LOG_IN_NAME' => $member['name'], 'EMAIL' => $member['email'], 'IP' => $member['ip_address'], 'DISPLAY_NAME' => $member['members_display_name']));
                 IPSText::getTextClass('email')->subject = sprintf($this->lang->words['new_registration_email1'], $this->settings['board_name']);
                 IPSText::getTextClass('email')->to = $this->settings['email_in'];
                 IPSText::getTextClass('email')->sendMail();
             }
             $this->registry->output->setTitle($this->lang->words['reg_success'] . ' - ' . ipsRegistry::$settings['board_name']);
             $this->registry->output->addNavigation($this->lang->words['nav_reg'], '');
         } else {
             /* We don't want to preview, or get them to validate via email. */
             $stat_cache = $this->cache->getCache('stats');
             if ($member['members_display_name'] and $member['member_id'] and !$this->caches['group_cache'][$member['member_group_id']]['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));
             /* Only send new registration email if the member wasn't banned */
             if ($this->settings['new_reg_notify'] and !$member['member_banned']) {
                 $date = $this->registry->class_localization->getDate(time(), 'LONG', 1);
                 IPSText::getTextClass('email')->getTemplate('admin_newuser');
                 IPSText::getTextClass('email')->buildMessage(array('DATE' => $date, 'LOG_IN_NAME' => $member['name'], 'EMAIL' => $member['email'], 'IP' => $member['ip_address'], 'DISPLAY_NAME' => $member['members_display_name']));
                 IPSText::getTextClass('email')->subject = sprintf($this->lang->words['new_registration_email1'], $this->settings['board_name']);
                 IPSText::getTextClass('email')->to = $this->settings['email_in'];
                 IPSText::getTextClass('email')->sendMail();
             }
             IPSCookie::set('pass_hash', $member['member_login_key'], 1);
             IPSCookie::set('member_id', $member['member_id'], 1);
             //-----------------------------------------
             // Fix up session
             //-----------------------------------------
             $privacy = $member['g_hide_online_list'] || empty($this->settings['disable_anonymous']) && !empty($this->request['Privacy']) ? 1 : 0;
             # Update value for onCompleteAccount call
             $member['login_anonymous'] = $privacy . '&1';
             $this->member->sessionClass()->convertGuestToMember(array('member_name' => $member['members_display_name'], 'member_id' => $member['member_id'], 'member_group' => $member['member_group_id'], 'login_type' => $privacy));
             IPSLib::runMemberSync('onCompleteAccount', $member);
             $this->registry->output->silentRedirect($this->settings['base_url'] . '&app=core&module=global&section=login&do=autologin&fromreg=1');
         }
     } else {
         /* This is a COPPA user, so lets tell them they registered OK and redirect to the form. */
         $this->DB->insert('validating', array('vid' => $validate_key, 'member_id' => $member['member_id'], 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => $time, 'coppa_user' => $coppa, 'new_reg' => 1, 'ip_address' => $member['ip_address']));
         $this->registry->output->redirectScreen($this->lang->words['cp_success'], $this->settings['base_url'] . 'app=core&amp;module=global&amp;section=register&amp;do=12');
     }
 }
 /**
  * UserCP Save Form: Settings
  *
  * @access	public
  * @return   array  Errors
  */
 public function saveForumSettings()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $_trackChoice = '';
     //-----------------------------------------
     // Check...
     //-----------------------------------------
     if (!in_array($this->request['postpage'], explode(',', $this->settings['postpage_contents']))) {
         $this->request['postpage'] = '-1';
     }
     if (!in_array($this->request['topicpage'], explode(',', $this->settings['topicpage_contents']))) {
         $this->request['topicpage'] = '-1';
     }
     //-----------------------------------------
     // Type of track
     //-----------------------------------------
     if ($this->request['auto_track']) {
         if (in_array($this->request['trackchoice'], array('none', 'immediate', 'delayed', 'daily', 'weekly'))) {
             $_trackChoice = $this->request['trackchoice'];
         }
     }
     IPSCookie::set('topicmode', $this->request['topic_display_mode'], 1);
     IPSMember::save($this->memberData['member_id'], array('core' => array('view_avs' => intval($this->request['viewAvatars']), 'view_sigs' => intval($this->request['viewSignatures']), 'view_img' => intval($this->request['viewImages']), 'email_full' => intval($this->request['send_full_msg']), 'auto_track' => $_trackChoice, 'view_prefs' => intval($this->request['postpage']) . "&" . intval($this->request['topicpage']))));
     IPSMember::packMemberCache($this->memberData['member_id'], array('qr_open' => intval($this->request['fastReplyOpen'])), $this->memberData['_cache']);
     return TRUE;
 }
Ejemplo n.º 21
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']);
 }
Ejemplo n.º 22
0
 /**
  * UserCP Save Form: Email Address
  *
  * @return	mixed		Array of errors / boolean true
  */
 public function saveFormEmailPassword()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $_emailOne = strtolower(trim($this->request['in_email_1']));
     $_emailTwo = strtolower(trim($this->request['in_email_2']));
     $cur_pass = trim($this->request['current_pass']);
     $new_pass = trim($this->request['new_pass_1']);
     $chk_pass = trim($this->request['new_pass_2']);
     $isRemote = (!$this->memberData['bw_local_password_set'] and $this->memberData['members_created_remote']) ? true : false;
     if ($cur_pass or $new_pass) {
         if ($this->memberData['g_access_cp']) {
             return array(0 => $this->lang->words['admin_emailpassword']);
         }
         if ($isRemote === false and (!$_POST['current_pass'] or empty($new_pass) or empty($chk_pass))) {
             return array(0 => $this->lang->words['complete_entire_form']);
         }
         //-----------------------------------------
         // Do the passwords actually match?
         //-----------------------------------------
         if ($new_pass != $chk_pass) {
             return array(0 => $this->lang->words['passwords_not_matchy']);
         }
         //-----------------------------------------
         // Check password...
         //-----------------------------------------
         if ($isRemote === false) {
             if ($this->_checkPassword($cur_pass) !== TRUE) {
                 return array(0 => $this->lang->words['current_pw_bad']);
             }
         } else {
             /* This is INIT in _checkPassword */
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
             $this->han_login = new $classToLoad($this->registry);
             $this->han_login->init();
         }
         //-----------------------------------------
         // Create new password...
         //-----------------------------------------
         $md5_pass = md5($new_pass);
         //-----------------------------------------
         // han_login was loaded during check_password
         //-----------------------------------------
         $this->han_login->changePass($this->memberData['email'], $md5_pass, $new_pass, $this->memberData);
         if ($this->han_login->return_code and $this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'SUCCESS') {
             return array(0 => $this->lang->words['hanlogin_pw_failed']);
         }
         //-----------------------------------------
         // Update the DB
         //-----------------------------------------
         IPSMember::updatePassword($this->memberData['email'], $md5_pass);
         IPSLib::runMemberSync('onPassChange', $this->memberData['member_id'], $new_pass);
         //-----------------------------------------
         // Update members log in key...
         //-----------------------------------------
         $key = IPSMember::generateAutoLoginKey();
         IPSMember::save($this->memberData['member_id'], array('core' => array('member_login_key' => $key, 'bw_local_password_set' => 1)));
         $this->ok_message = $this->lang->words['pw_change_successful'];
     }
     if ($_emailOne or $_emailTwo) {
         //-----------------------------------------
         // Do not allow validating members to change
         // email when admin validation is on
         // @see	http://community.invisionpower.com/tracker/issue-19964-loophole-in-registration-procedure/
         //-----------------------------------------
         if ($this->memberData['member_group_id'] == $this->settings['auth_group'] and in_array($this->settings['reg_auth_type'], array('admin', 'admin_user'))) {
             $this->registry->output->showError($this->lang->words['admin_val_no_email_chg'], 10190);
         }
         //-----------------------------------------
         // Check input
         //-----------------------------------------
         if ($this->memberData['g_access_cp']) {
             return array(0 => $this->lang->words['admin_emailpassword']);
         }
         if (!$_POST['in_email_1'] or !$_POST['in_email_2']) {
             return array(0 => $this->lang->words['complete_entire_form']);
         }
         //-----------------------------------------
         // Check password...
         //-----------------------------------------
         if (!$this->_isFBUser) {
             if ($this->_checkPassword($this->request['password']) === FALSE) {
                 return array(0 => $this->lang->words['current_pw_bad']);
             }
         }
         //-----------------------------------------
         // Test email addresses
         //-----------------------------------------
         if ($_emailOne != $_emailTwo) {
             return array(0 => $this->lang->words['emails_no_matchy']);
         }
         if (IPSText::checkEmailAddress($_emailOne) !== TRUE) {
             return array(0 => $this->lang->words['email_not_valid']);
         }
         //-----------------------------------------
         // Is this email addy taken?
         //-----------------------------------------
         if (IPSMember::checkByEmail($_emailOne) == TRUE) {
             return array(0 => $this->lang->words['email_is_taken']);
         }
         //-----------------------------------------
         // Load ban filters
         //-----------------------------------------
         $banfilters = array();
         $this->DB->build(array('select' => '*', 'from' => 'banfilters'));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             $banfilters[$r['ban_type']][] = $r['ban_content'];
         }
         //-----------------------------------------
         // Check in banned list
         //-----------------------------------------
         if (isset($banfilters['email']) and is_array($banfilters['email']) and count($banfilters['email'])) {
             foreach ($banfilters['email'] as $email) {
                 $email = str_replace('\\*', '.*', preg_quote($email, "/"));
                 if (preg_match("/^{$email}\$/i", $_emailOne)) {
                     return array(0 => $this->lang->words['email_is_taken']);
                 }
             }
         }
         //-----------------------------------------
         // 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();
         if ($this->han_login->emailExistsCheck($_emailOne) !== FALSE) {
             return array(0 => $this->lang->words['email_is_taken']);
         }
         $this->han_login->changeEmail($this->memberData['email'], $_emailOne, $this->memberData);
         if ($this->han_login->return_code and $this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'SUCCESS') {
             return array(0 => $this->lang->words['email_is_taken']);
         }
         //-----------------------------------------
         // Want a new validation? NON ADMINS ONLY
         //-----------------------------------------
         if ($this->settings['reg_auth_type'] and !$this->memberData['g_access_cp']) {
             //-----------------------------------------
             // Remove any existing entries
             //-----------------------------------------
             $_previous = $this->DB->buildAndFetch(array('select' => 'prev_email, real_group', 'from' => 'validating', 'where' => "member_id={$this->memberData['member_id']} AND email_chg=1"));
             if ($_previous['prev_email']) {
                 $this->DB->delete('validating', "member_id={$this->memberData['member_id']} AND email_chg=1");
                 $this->memberData['email'] = $_previous['prev_email'];
                 $this->memberData['member_group_id'] = $_previous['real_group'];
             }
             $validate_key = md5(IPSMember::makePassword() . time());
             //-----------------------------------------
             // Update the new email, but enter a validation key
             // and put the member in "awaiting authorisation"
             // and send an email..
             //-----------------------------------------
             $db_str = array('vid' => $validate_key, 'member_id' => $this->memberData['member_id'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => time(), 'coppa_user' => 0, 'email_chg' => 1, 'ip_address' => $this->member->ip_address, 'prev_email' => $this->memberData['email']);
             if ($this->memberData['member_group_id'] != $this->settings['auth_group']) {
                 $db_str['real_group'] = $this->memberData['member_group_id'];
             }
             $this->DB->insert('validating', $db_str);
             IPSLib::runMemberSync('onEmailChange', $this->memberData['member_id'], strtolower($_emailOne), $this->memberData['email']);
             IPSMember::save($this->memberData['member_id'], array('core' => array('member_group_id' => $this->settings['auth_group'], 'email' => $_emailOne)));
             //-----------------------------------------
             // Update their session with the new member group
             //-----------------------------------------
             if ($this->member->session_id) {
                 $this->member->sessionClass()->convertMemberToGuest();
             }
             //-----------------------------------------
             // Kill the cookies to stop auto log in
             //-----------------------------------------
             IPSCookie::set('pass_hash', '-1', 0);
             IPSCookie::set('member_id', '-1', 0);
             IPSCookie::set('session_id', '-1', 0);
             //-----------------------------------------
             // Dispatch the mail, and return to the activate form.
             //-----------------------------------------
             IPSText::getTextClass('email')->getTemplate("newemail");
             IPSText::getTextClass('email')->buildMessage(array('NAME' => $this->memberData['members_display_name'], 'THE_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global&section=register&do=auto_validate&type=newemail&uid=" . $this->memberData['member_id'] . "&aid=" . $validate_key, 'publicNoSession', 'false'), 'ID' => $this->memberData['member_id'], 'MAN_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global&section=register&do=07", 'publicNoSession', 'false'), 'CODE' => $validate_key));
             IPSText::getTextClass('email')->subject = $this->lang->words['lp_subject'] . ' ' . $this->settings['board_name'];
             IPSText::getTextClass('email')->to = $_emailOne;
             IPSText::getTextClass('email')->sendMail();
             $this->registry->getClass('output')->silentRedirect($this->settings['base_url'] . 'app=core&amp;module=global&amp;section=register&amp;do=07');
         } else {
             //-----------------------------------------
             // No authorisation needed, change email addy and return
             //-----------------------------------------
             IPSLib::runMemberSync('onEmailChange', $this->memberData['member_id'], strtolower($_emailOne), $this->memberData['email']);
             IPSMember::save($this->memberData['member_id'], array('core' => array('email' => $_emailOne)));
             //-----------------------------------------
             // Add to OK message
             //-----------------------------------------
             $this->ok_message = $this->lang->words['ok_email_changed'];
         }
     }
     return TRUE;
 }
 /**
  * Processes the registration form
  *
  * @access	public
  * @return	void
  */
 public function registerProcessForm()
 {
     $form_errors = array();
     $coppa = $this->request['coppa_user'] == 1 ? 1 : 0;
     $in_password = trim($this->request['PassWord']);
     $in_email = strtolower(trim($this->request['EmailAddress']));
     $_SFS_FOUND = FALSE;
     /* Check */
     if ($this->settings['no_reg'] == 1) {
         $this->registry->output->showError('registration_disabled', 2016, true);
     }
     /* Custom profile field stuff */
     require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
     $custom_fields = new customProfileFields();
     $custom_fields->initData('edit');
     $custom_fields->parseToSave($this->request, 'register');
     /* Check */
     if ($custom_fields->error_messages) {
         $form_errors['general'] = $custom_fields->error_messages;
     }
     /* Check the email address */
     if (!$in_email or strlen($in_email) < 6 or !IPSText::checkEmailAddress($in_email)) {
         $form_errors['email'][$this->lang->words['err_invalid_email']] = $this->lang->words['err_invalid_email'];
     }
     if (trim($this->request['PassWord_Check']) != $in_password) {
         $form_errors['password'][$this->lang->words['passwords_not_match']] = $this->lang->words['passwords_not_match'];
     }
     /* Test email address */
     $this->request['EmailAddress_two'] = strtolower(trim($this->request['EmailAddress_two']));
     $this->request['EmailAddress'] = strtolower(trim($this->request['EmailAddress']));
     if (!IPSText::checkEmailAddress($this->request['EmailAddress_two'])) {
         $form_errors['email'][$this->lang->words['reg_error_email_invalid']] = $this->lang->words['reg_error_email_invalid'];
     } else {
         if ($in_email and $this->request['EmailAddress_two'] != $in_email) {
             $form_errors['email'][$this->lang->words['reg_error_email_nm']] = $this->lang->words['reg_error_email_nm'];
         }
     }
     /* Need username? */
     $uses_name = false;
     foreach ($this->cache->getCache('login_methods') as $method) {
         if ($method['login_user_id'] == 'username') {
             $uses_name = true;
         }
     }
     if (!$uses_name) {
         $_REQUEST['UserName'] = $_REQUEST['members_display_name'];
         $this->request['UserName'] = $this->request['members_display_name'];
     }
     /* Check the username */
     $user_check = IPSMember::getFunction()->cleanAndCheckName($this->request['UserName'], array(), 'name');
     if ($this->settings['auth_allow_dnames']) {
         $disp_check = IPSMember::getFunction()->cleanAndCheckName($this->request['members_display_name'], array(), 'members_display_name');
     }
     if (is_array($user_check['errors']) && count($user_check['errors'])) {
         foreach ($user_check['errors'] as $key => $error) {
             $form_errors[$key][] = $error;
         }
     }
     if ($this->settings['auth_allow_dnames'] and is_array($disp_check['errors']) && count($disp_check['errors'])) {
         foreach ($disp_check['errors'] as $key => $error) {
             $form_errors[$key][] = $error;
         }
     }
     /* CHECK 1: Any errors (missing fields, etc)? */
     if (count($form_errors)) {
         $this->registerForm($form_errors);
         return;
     }
     /* Is this email addy taken? */
     if (IPSMember::checkByEmail($in_email) == TRUE) {
         $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken'];
     }
     /* Load handler... */
     require_once IPS_ROOT_PATH . 'sources/handlers/han_login.php';
     $this->han_login = new han_login($this->registry);
     $this->han_login->init();
     $this->han_login->emailExistsCheck($in_email);
     if ($this->han_login->return_code and $this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'EMAIL_NOT_IN_USE') {
         $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken'];
     }
     /* Are they banned [EMAIL]? */
     if (IPSMember::isBanned('email', $in_email) === TRUE) {
         $form_errors['email'][$this->lang->words['reg_error_email_ban']] = $this->lang->words['reg_error_email_ban'];
     }
     /* Check the CAPTCHA */
     if ($this->settings['bot_antispam']) {
         if ($this->registry->getClass('class_captcha')->validate() !== TRUE) {
             $form_errors['general'][$this->lang->words['err_reg_code']] = $this->lang->words['err_reg_code'];
         }
     }
     /* Check the Q and A */
     if ($this->settings['registration_qanda']) {
         $qanda = intval($this->request['qanda_id']);
         $pass = false;
         if ($qanda) {
             $data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'question_and_answer', 'where' => 'qa_id=' . $qanda));
             if ($data['qa_id']) {
                 $answers = explode("\n", str_replace("\r", "", $data['qa_answers']));
                 if (count($answers)) {
                     foreach ($answers as $answer) {
                         if (strtolower($answer) == strtolower($this->request['qa_answer'])) {
                             $pass = true;
                             break;
                         }
                     }
                 }
             }
         } else {
             //-----------------------------------------
             // Do we have any questions?
             //-----------------------------------------
             $data = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as questions', 'from' => 'question_and_answer'));
             if (!$data['questions']) {
                 $pass = true;
             }
         }
         if (!$pass) {
             $form_errors['general'][$this->lang->words['err_q_and_a']] = $this->lang->words['err_q_and_a'];
         }
     }
     /* CHECK 2: Any errors ? */
     if (count($form_errors)) {
         $this->registerForm($form_errors);
         return;
     }
     /* Build up the hashes */
     $mem_group = $this->settings['member_group'];
     /* Are we asking the member or admin to preview? */
     if ($this->settings['reg_auth_type']) {
         $mem_group = $this->settings['auth_group'];
     } else {
         if ($coppa == 1) {
             $mem_group = $this->settings['auth_group'];
         }
     }
     /* Create member */
     $member = array('name' => $this->request['UserName'], 'password' => $in_password, 'members_display_name' => $this->settings['auth_allow_dnames'] ? $this->request['members_display_name'] : $this->request['UserName'], 'email' => $in_email, 'member_group_id' => $mem_group, 'joined' => time(), 'ip_address' => $this->member->ip_address, 'time_offset' => $this->request['time_offset'], 'coppa_user' => $coppa, 'members_auto_dst' => intval($this->request['dst']), 'allow_admin_mails' => intval($this->request['allow_admin_mail']), 'hide_email' => $this->request['allow_member_mail'] ? 0 : 1);
     /* Spam Service */
     $spamCode = 0;
     if ($this->settings['spam_service_enabled'] && $this->settings['spam_service_api_key']) {
         /* Query the service */
         $spamCode = IPSMember::querySpamService($in_email);
         /* Action to perform */
         $action = $this->settings['spam_service_action_' . $spamCode];
         /* Perform Action */
         switch ($action) {
             /* Proceed with registraction */
             case 1:
                 break;
                 /* Flag for admin approval */
             /* Flag for admin approval */
             case 2:
                 $member['member_group_id'] = $this->settings['auth_group'];
                 $this->settings['reg_auth_type'] = 'admin';
                 break;
                 /* Approve the account, but ban it */
             /* Approve the account, but ban it */
             case 3:
                 $member['member_banned'] = 1;
                 $member['member_group_id'] = $this->settings['banned_group'];
                 $this->settings['reg_auth_type'] = '';
                 break;
         }
     }
     //-----------------------------------------
     // Create the account
     //-----------------------------------------
     $member = IPSMember::create(array('members' => $member, 'pfields_content' => $this->request));
     //-----------------------------------------
     // Login handler create account callback
     //-----------------------------------------
     $this->han_login->createAccount(array('email' => $member['email'], 'joined' => $member['joined'], 'password' => $in_password, 'ip_address' => $this->member->ip_address, 'username' => $member['members_display_name']));
     //-----------------------------------------
     // We'll just ignore if this fails - it shouldn't hold up IPB anyways
     //-----------------------------------------
     /*if ( $han_login->return_code AND ( $han_login->return_code != 'METHOD_NOT_DEFINED' AND $han_login->return_code != 'SUCCESS' ) )
     		{
     			$this->registry->output->showError( 'han_login_create_failed', 2017, true );
     		}*/
     //-----------------------------------------
     // Validation
     //-----------------------------------------
     $validate_key = md5(IPSLib::makePassword() . time());
     $time = time();
     if ($coppa != 1) {
         if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin' or $this->settings['reg_auth_type'] == 'admin_user') {
             //-----------------------------------------
             // We want to validate all reg's via email,
             // after email verificiation has taken place,
             // we restore their previous group and remove the validate_key
             //-----------------------------------------
             $this->DB->insert('validating', array('vid' => $validate_key, 'member_id' => $member['member_id'], 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => $time, 'coppa_user' => $coppa, 'new_reg' => 1, 'ip_address' => $member['ip_address']));
             if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin_user') {
                 IPSText::getTextClass('email')->getTemplate("reg_validate");
                 IPSText::getTextClass('email')->buildMessage(array('THE_LINK' => $this->settings['base_url'] . "app=core&module=global&section=register&do=auto_validate&uid=" . urlencode($member['member_id']) . "&aid=" . urlencode($validate_key), 'NAME' => $member['members_display_name'], 'MAN_LINK' => $this->settings['base_url'] . "app=core&module=global&section=register&do=05", 'EMAIL' => $member['email'], 'ID' => $member['member_id'], 'CODE' => $validate_key));
                 IPSText::getTextClass('email')->subject = $this->lang->words['new_registration_email'] . $this->settings['board_name'];
                 IPSText::getTextClass('email')->to = $member['email'];
                 IPSText::getTextClass('email')->sendMail();
                 $this->output = $this->registry->output->getTemplate('register')->showAuthorize($member);
             } else {
                 if ($this->settings['reg_auth_type'] == 'admin') {
                     $this->output = $this->registry->output->getTemplate('register')->showPreview($member);
                 }
             }
             if ($this->settings['new_reg_notify']) {
                 $date = $this->registry->class_localization->getDate(time(), 'LONG', 1);
                 IPSText::getTextClass('email')->getTemplate('admin_newuser');
                 IPSText::getTextClass('email')->buildMessage(array('DATE' => $date, 'MEMBER_NAME' => $member['members_display_name']));
                 IPSText::getTextClass('email')->subject = $this->lang->words['new_registration_email1'] . $this->settings['board_name'];
                 IPSText::getTextClass('email')->to = $this->settings['email_in'];
                 IPSText::getTextClass('email')->sendMail();
             }
             $this->registry->output->setTitle($this->lang->words['reg_success']);
             $this->registry->output->addNavigation($this->lang->words['nav_reg'], '');
         } else {
             /* We don't want to preview, or get them to validate via email. */
             $stat_cache = $this->caches['stats'];
             if ($member['members_display_name'] and $member['member_id']) {
                 $stat_cache['last_mem_name'] = $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, 'deletefirst' => 0));
             if ($this->settings['new_reg_notify']) {
                 $date = $this->registry->class_localization->getDate(time(), 'LONG', 1);
                 IPSText::getTextClass('email')->getTemplate('admin_newuser');
                 IPSText::getTextClass('email')->buildMessage(array('DATE' => $date, 'MEMBER_NAME' => $member['members_display_name']));
                 IPSText::getTextClass('email')->subject = $this->lang->words['new_registration_email1'] . $this->settings['board_name'];
                 IPSText::getTextClass('email')->to = $this->settings['email_in'];
                 IPSText::getTextClass('email')->sendMail();
             }
             IPSCookie::set('pass_hash', $member['member_login_key'], 1);
             IPSCookie::set('member_id', $member['member_id'], 1);
             //-----------------------------------------
             // Fix up session
             //-----------------------------------------
             $privacy = $this->request['Privacy'] ? 1 : 0;
             if ($member['g_hide_online_list']) {
                 $privacy = 1;
             }
             $this->member->sessionClass()->convertGuestToMember(array('member_name' => $member['members_display_name'], 'member_id' => $member['member_id'], 'member_group' => $member['member_group_id'], 'login_type' => $privacy));
             $this->registry->output->silentRedirect($this->settings['base_url'] . '&app=core&module=global&section=login&do=autologin&fromreg=1');
         }
     } else {
         /* This is a COPPA user, so lets tell them they registered OK and redirect to the form. */
         $this->DB->insert('validating', array('vid' => $validate_key, 'member_id' => $member['member_id'], 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => $time, 'coppa_user' => $coppa, 'new_reg' => 1, 'ip_address' => $member['ip_address']));
         $this->registry->output->redirectScreen($this->lang->words['cp_success'], $this->settings['base_url'] . 'app=core&amp;module=global&amp;section=register&amp;do=12');
     }
 }
Ejemplo n.º 24
0
 /**
  * Builds an array of forum data for use in the output template
  *
  * @return	array
  */
 public function renderForum()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['page'] = $this->request['changefilters'] ? 0 : (isset($this->request['page']) ? intval($this->request['page']) : 0);
     $announce_data = array();
     $topic_data = array();
     $other_data = array();
     $multi_mod_data = array();
     $footer_filter = array();
     $member_ids = array();
     //-----------------------------------------
     // Show?
     //-----------------------------------------
     if (isset($this->request['show']) and $this->request['show'] == 'sinceLastVisit') {
         $this->request['prune_day'] = 200;
     }
     //-----------------------------------------
     // Are we actually a moderator for this forum?
     //-----------------------------------------
     $mod = $this->memberData['forumsModeratorData'];
     if (!$this->memberData['g_is_supmod']) {
         if (!isset($mod[$this->forum['id']]) or !is_array($mod[$this->forum['id']])) {
             $this->memberData['is_mod'] = 0;
         }
     }
     //-----------------------------------------
     // Announcements
     //-----------------------------------------
     if (is_array($this->registry->cache()->getCache('announcements')) and count($this->registry->cache()->getCache('announcements'))) {
         $announcements = array();
         foreach ($this->registry->cache()->getCache('announcements') as $announce) {
             $order = $announce['announce_start'] ? $announce['announce_start'] . ',' . $announce['announce_id'] : $announce['announce_id'];
             if ($announce['announce_forum'] == '*') {
                 $announcements[$order] = $announce;
             } else {
                 if (strstr(',' . $announce['announce_forum'] . ',', ',' . $this->forum['id'] . ',')) {
                     $announcements[$order] = $announce;
                 }
             }
         }
         if (count($announcements)) {
             //-----------------------------------------
             // sort by start date
             //-----------------------------------------
             krsort($announcements);
             foreach ($announcements as $announce) {
                 if ($announce['announce_start']) {
                     $announce['announce_start'] = $this->lang->getDate($announce['announce_start'], 'date');
                 } else {
                     $announce['announce_start'] = '--';
                 }
                 $announce['announce_title'] = IPSText::stripslashes($announce['announce_title']);
                 $announce['forum_id'] = $this->forum['id'];
                 $announce['announce_views'] = intval($announce['announce_views']);
                 $announce_data[] = $announce;
                 $member_ids[$announce['member_id']] = $announce['member_id'];
             }
             $this->forum['_showAnnouncementsBar'] = 1;
         }
     }
     //-----------------------------------------
     // Read topics
     //-----------------------------------------
     $First = $this->registry->class_forums->pageToSt(intval($this->request['page']));
     //-----------------------------------------
     // Sort options
     //-----------------------------------------
     $cookie_prune = IPSCookie::get($this->forum['id'] . "_prune_day");
     $cookie_sort = IPSCookie::get($this->forum['id'] . "_sort_key");
     $cookie_sortb = IPSCookie::get($this->forum['id'] . "_sort_by");
     $cookie_fill = IPSCookie::get($this->forum['id'] . "_topicfilter");
     $prune_value = $this->selectVariable(array(1 => !empty($this->request['prune_day']) ? $this->request['prune_day'] : NULL, 2 => !empty($cookie_prune) ? $cookie_prune : NULL, 3 => $this->forum['prune'], 4 => '100'));
     $sort_key = $this->selectVariable(array(1 => !empty($this->request['sort_key']) ? $this->request['sort_key'] : NULL, 2 => !empty($cookie_sort) ? $cookie_sort : NULL, 3 => $this->forum['sort_key'], 4 => 'last_post'));
     $sort_by = $this->selectVariable(array(1 => !empty($this->request['sort_by']) ? $this->request['sort_by'] : NULL, 2 => !empty($cookie_sortb) ? $cookie_sortb : NULL, 3 => $this->forum['sort_order'], 4 => 'Z-A'));
     $topicfilter = $this->selectVariable(array(1 => !empty($this->request['topicfilter']) ? $this->request['topicfilter'] : NULL, 2 => !empty($cookie_fill) ? $cookie_fill : NULL, 3 => $this->forum['topicfilter'], 4 => 'all'));
     if (!empty($this->request['remember'])) {
         if ($this->request['prune_day']) {
             IPSCookie::set($this->forum['id'] . "_prune_day", $this->request['prune_day']);
         }
         if ($this->request['sort_key']) {
             IPSCookie::set($this->forum['id'] . "_sort_key", $this->request['sort_key']);
         }
         if ($this->request['sort_by']) {
             IPSCookie::set($this->forum['id'] . "_sort_by", $this->request['sort_by']);
         }
         if ($this->request['topicfilter']) {
             IPSCookie::set($this->forum['id'] . "_topicfilter", $this->request['topicfilter']);
         }
     }
     //-----------------------------------------
     // Figure out sort order, day cut off, etc
     //-----------------------------------------
     $Prune = $prune_value < 100 ? time() - $prune_value * 60 * 60 * 24 : (($prune_value == 200 and $this->memberData['member_id']) ? $this->memberData['last_visit'] : 0);
     $sort_keys = array('last_post' => 'sort_by_date', 'last_poster_name' => 'sort_by_last_poster', 'title' => 'sort_by_topic', 'starter_name' => 'sort_by_poster', 'start_date' => 'sort_by_start', 'topic_hasattach' => 'sort_by_attach', 'posts' => 'sort_by_replies', 'views' => 'sort_by_views');
     $prune_by_day = array('1' => 'show_today', '5' => 'show_5_days', '7' => 'show_7_days', '10' => 'show_10_days', '15' => 'show_15_days', '20' => 'show_20_days', '25' => 'show_25_days', '30' => 'show_30_days', '60' => 'show_60_days', '90' => 'show_90_days', '100' => 'show_all', '200' => 'show_last_visit');
     $sort_by_keys = array('Z-A' => 'descending_order', 'A-Z' => 'ascending_order');
     $filter_keys = array('all' => 'topicfilter_all', 'open' => 'topicfilter_open', 'hot' => 'topicfilter_hot', 'poll' => 'topicfilter_poll', 'locked' => 'topicfilter_locked', 'moved' => 'topicfilter_moved');
     if ($this->memberData['member_id']) {
         $filter_keys['istarted'] = 'topicfilter_istarted';
         $filter_keys['ireplied'] = 'topicfilter_ireplied';
     }
     //-----------------------------------------
     // check for any form funny business by wanna-be hackers
     //-----------------------------------------
     if (!isset($filter_keys[$topicfilter]) or !isset($sort_keys[$sort_key]) or !isset($prune_by_day[$prune_value]) or !isset($sort_by_keys[strtoupper($sort_by)])) {
         $this->registry->getClass('output')->showError('forums_bad_filter', 10339);
     }
     $r_sort_by = $sort_by == 'A-Z' ? 'ASC' : 'DESC';
     //-----------------------------------------
     // If sorting by starter, add secondary..
     //-----------------------------------------
     $sort_key_chk = $sort_key;
     if ($sort_key == 'starter_name') {
         $sort_key = "starter_name {$r_sort_by}, t.last_post DESC";
         $r_sort_by = '';
     }
     //-----------------------------------------
     // Additional queries?
     //-----------------------------------------
     $add_query_array = array();
     $add_query = "";
     switch ($topicfilter) {
         case 'all':
             break;
         case 'open':
             $add_query_array[] = "t.state='open'";
             break;
         case 'hot':
             $add_query_array[] = "t.state='open' AND t.posts + 1 >= " . intval($this->settings['hot_topic']);
             break;
         case 'locked':
             $add_query_array[] = "t.state='closed'";
             break;
         case 'moved':
             $add_query_array[] = "t.state='link'";
             break;
         case 'poll':
             $add_query_array[] = "(t.poll_state='open' OR t.poll_state=1)";
             break;
         default:
             break;
     }
     if (!$this->memberData['g_other_topics'] or $topicfilter == 'istarted' or !$this->forum['can_view_others'] and !$this->memberData['is_mod']) {
         $add_query_array[] = "t.starter_id='" . $this->memberData['member_id'] . "'";
     }
     /* Answered / unanswered */
     if (isset($this->request['answered']) && $this->registry->class_forums->answerTopicsEnabled($this->forum['id'])) {
         if ($this->request['answered'] == 'true') {
             $add_query_array[] = 't.topic_answered_pid != 0';
         } else {
             if ($this->request['answered'] == 'false') {
                 $add_query_array[] = 't.topic_answered_pid = 0';
             }
         }
     }
     $_SQL_EXTRA = '';
     $_SQL_APPROVED = '';
     $_SQL_AGE_PRUNE = '';
     if (count($add_query_array)) {
         $_SQL_EXTRA = ' AND ' . implode(' AND ', $add_query_array);
     }
     //-----------------------------------------
     // Moderator?
     //-----------------------------------------
     $this->request['modfilter'] = isset($this->request['modfilter']) ? $this->request['modfilter'] : '';
     $modFilter = '';
     if ($this->memberData['is_mod']) {
         if ($this->request['modfilter'] == 'unapproved') {
             $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('hidden'), 't.') . ' OR t.topic_queuedposts';
         } elseif ($this->permissions['TopicSoftDeleteSee']) {
             if ($this->request['modfilter'] == 'hidden') {
                 $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('sdeleted'), 't.') . ' OR t.topic_deleted_posts';
             } else {
                 $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible', 'hidden', 'sdeleted'), 't.');
             }
         } else {
             $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible', 'hidden'), 't.');
         }
     } else {
         if ($this->permissions['TopicSoftDeleteSee']) {
             $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible', 'sdeleted'), 't.');
         } else {
             $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible'), 't.');
         }
     }
     if ($modFilter) {
         $_SQL_APPROVED = ' AND (' . $modFilter . ')';
     }
     if ($Prune) {
         if ($prune_value == 200) {
             /* Just new content, don't show pinned, please */
             if ($modFilter) {
                 $_SQL_AGE_PRUNE = " AND (t.last_post > {$Prune} AND ( {$modFilter} ) )";
             } else {
                 $_SQL_AGE_PRUNE = " AND (t.last_post > {$Prune})";
             }
         } else {
             if ($modFilter) {
                 $_SQL_AGE_PRUNE = " AND (t.pinned=1 or t.last_post > {$Prune} AND ( {$modFilter} ) )";
             } else {
                 $_SQL_AGE_PRUNE = " AND (t.pinned=1 or t.last_post > {$Prune})";
             }
         }
     }
     //-----------------------------------------
     // Query the database to see how many topics there are in the forum
     //-----------------------------------------
     if ($topicfilter == 'ireplied') {
         //-----------------------------------------
         // Checking topics we've replied to?
         //-----------------------------------------
         $this->DB->build(array('select' => 'COUNT(' . $this->DB->buildDistinct('p.topic_id') . ') as max', 'from' => array('topics' => 't'), 'where' => "t.forum_id={$this->forum['id']} AND p.author_id=" . $this->memberData['member_id'] . " AND p.new_topic=0" . $_SQL_APPROVED . $_SQL_AGE_PRUNE, 'add_join' => array(array('from' => array('posts' => 'p'), 'where' => 'p.topic_id=t.tid'))));
         $this->DB->execute();
         $total_possible = $this->DB->fetch();
     } else {
         if ($_SQL_EXTRA or $_SQL_AGE_PRUNE or $this->request['modfilter']) {
             $this->DB->build(array('select' => 'COUNT(*) as max', 'from' => 'topics t', 'where' => "t.forum_id=" . $this->forum['id'] . $_SQL_APPROVED . $_SQL_AGE_PRUNE . $_SQL_EXTRA));
             $this->DB->execute();
             $total_possible = $this->DB->fetch();
         } else {
             $total_possible['max'] = $this->memberData['is_mod'] ? $this->forum['topics'] + $this->forum['queued_topics'] : $this->forum['topics'];
             if ($this->permissions['TopicSoftDeleteSee'] and $this->forum['deleted_topics']) {
                 $total_possible['max'] += intval($this->forum['deleted_topics']);
             }
             $Prune = 0;
         }
     }
     //-----------------------------------------
     // Generate the forum page span links
     //-----------------------------------------
     $_extraStuff = '';
     if ($this->request['modfilter']) {
         $_extraStuff .= "&amp;modfilter=" . $this->request['modfilter'];
     }
     if (isset($this->request['answered']) && $this->registry->class_forums->answerTopicsEnabled($this->forum['id'])) {
         $_extraStuff .= "&amp;answered=" . $this->request['answered'];
     }
     $this->forum['SHOW_PAGES'] = $this->registry->getClass('output')->generatePagination(array('totalItems' => $total_possible['max'], 'itemsPerPage' => $this->settings['display_max_topics'], 'currentStartValue' => intval($this->request['page']), 'isPagesMode' => true, 'seoTitle' => $this->forum['name_seo'], 'disableSinglePage' => false, 'baseUrl' => "showforum=" . $this->forum['id'] . "&amp;prune_day={$prune_value}&amp;sort_by={$sort_by}&amp;sort_key={$sort_key_chk}&amp;topicfilter={$topicfilter}{$_extraStuff}"));
     //-----------------------------------------
     // Start printing the page
     //-----------------------------------------
     $other_data = array('forum_data' => $this->forum, 'hasMore' => $this->registry->class_forums->pageToSt($this->request['page']) + $this->settings['display_max_topics'] > $total_possible['max'] ? false : true, 'can_edit_topics' => $this->can_edit_topics, 'can_open_topics' => $this->can_open_topics, 'can_close_topics' => $this->can_close_topics, 'can_move_topics' => $this->can_move_topics);
     $total_topics_printed = 0;
     //-----------------------------------------
     // Get main topics
     //-----------------------------------------
     $topic_array = array();
     $topic_ids = array();
     $topic_sort = "";
     //-----------------------------------------
     // Cut off?
     //-----------------------------------------
     $modAll = ($this->memberData['g_is_supmod'] or isset($this->memberData['forumsModeratorData'][$this->forum['id']]) and ($this->memberData['forumsModeratorData'][$this->forum['id']]['delete_topic'] or $this->memberData['forumsModeratorData'][$this->forum['id']]['move_topic'] or $this->memberData['forumsModeratorData'][$this->forum['id']]['split_merge']));
     $parse_dots = 1;
     if ($topicfilter == 'ireplied') {
         //-----------------------------------------
         // Checking topics we've replied to?
         // No point in getting dots again...
         //-----------------------------------------
         $parse_dots = 0;
         $_joins = array(array('select' => 't.*', 'from' => array('posts' => 'p'), 'where' => 'p.topic_id=t.tid AND p.author_id=' . $this->memberData['member_id']));
         if ($this->settings['tags_enabled'] and !$this->forum['bw_disable_tagging']) {
             $_joins[] = $this->registry->tags->getCacheJoin(array('meta_id_field' => 't.tid'));
         }
         // For some reason, mySQL doesn't like the distinct + t.* being in reverse order...
         $this->DB->build(array('select' => $this->DB->buildDistinct('p.author_id'), 'from' => array('topics' => 't'), 'where' => "t.forum_id=" . $this->forum['id'] . " AND t.pinned IN (0,1)" . $_SQL_APPROVED . $_SQL_AGE_PRUNE . " AND p.new_topic=0", 'order' => "t.pinned desc,{$topic_sort} t.{$sort_key} {$r_sort_by}", 'limit' => array(intval($First), intval($this->settings['display_max_topics'])), 'add_join' => $_joins));
         $this->DB->execute();
     } else {
         $this->DB->build(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => "t.forum_id=" . $this->forum['id'] . " AND t.pinned IN (0,1)" . $_SQL_APPROVED . $_SQL_AGE_PRUNE . $_SQL_EXTRA, 'order' => 't.pinned DESC, ' . $topic_sort . ' t.' . $sort_key . ' ' . $r_sort_by, 'limit' => array(intval($First), $this->settings['display_max_topics']), 'add_join' => ($this->settings['tags_enabled'] and !$this->forum['bw_disable_tagging']) ? array($this->registry->tags->getCacheJoin(array('meta_id_field' => 't.tid'))) : array()));
         $this->DB->execute();
     }
     while ($t = $this->DB->fetch()) {
         /* Should we display the moderate checkbox for this post? */
         $t['moddable'] = FALSE;
         if ($modAll or isset($this->memberData['forumsModeratorData'][$this->forum['id']]) and ($t['pinned'] == 0 and $this->memberData['forumsModeratorData'][$this->forum['id']]['pin_topic'] or $t['pinned'] == 1 and $this->memberData['forumsModeratorData'][$this->forum['id']]['unpin_topic'] or $t['state'] == 'open' and $this->memberData['forumsModeratorData'][$this->forum['id']]['close_topic'] or $t['state'] == 'closed' and $this->memberData['forumsModeratorData'][$this->forum['id']]['open_topic'])) {
             $t['moddable'] = TRUE;
         }
         /* Add to array */
         $topic_array[$t['tid']] = $t;
         $topic_ids[$t['tid']] = $t['tid'];
         if ($t['last_poster_id']) {
             $member_ids[$t['last_poster_id']] = $t['last_poster_id'];
         }
         if ($t['starter_id']) {
             $member_ids[$t['starter_id']] = $t['starter_id'];
         }
     }
     ksort($topic_ids);
     //-----------------------------------------
     // Are we dotty?
     //-----------------------------------------
     if ($this->settings['show_user_posted'] == 1 and $this->memberData['member_id'] and count($topic_ids) and $parse_dots) {
         $_queued = $this->registry->class_forums->fetchPostHiddenQuery(array('visible'), '');
         $this->DB->build(array('select' => $this->DB->buildDistinct('topic_id'), 'from' => 'posts', 'where' => $_queued . ' AND author_id=' . $this->memberData['member_id'] . ' AND topic_id IN(' . implode(',', $topic_ids) . ')'));
         $this->DB->execute();
         while ($p = $this->DB->fetch()) {
             if (is_array($topic_array[$p['topic_id']])) {
                 $topic_array[$p['topic_id']]['author_id'] = $this->memberData['member_id'];
             }
         }
     }
     //-----------------------------------------
     // Get needed members
     //-----------------------------------------
     if (count($member_ids)) {
         $_members = IPSMember::load($member_ids);
         //-----------------------------------------
         // Add member data to announcements
         //-----------------------------------------
         $new_announces = array();
         foreach ($announce_data as $announce) {
             $announce = array_merge($announce, IPSMember::buildDisplayData($_members[$announce['member_id']]));
             $new_announces[] = $announce;
         }
         $announce_data = $new_announces;
     }
     //-----------------------------------------
     // Show meh the topics!
     //-----------------------------------------
     $adCodeSet = false;
     foreach ($topic_array as $topic) {
         /* Add member */
         if ($topic['last_poster_id']) {
             $topic = array_merge(IPSMember::buildDisplayData($_members[$topic['last_poster_id']]), $topic);
         } else {
             $topic = array_merge(IPSMember::buildProfilePhoto(array()), $topic);
         }
         if ($topic['starter_id']) {
             $topic['_starter'] = $_members[$topic['starter_id']];
         }
         /* AD Code */
         if ($this->registry->getClass('IPSAdCode')->userCanViewAds() && !$adCodeSet) {
             $topic['_adCode'] = $this->registry->getClass('IPSAdCode')->getAdCode('ad_code_forum_view_topic_code');
             if ($topic['_adCode']) {
                 $adCodeSet = true;
             }
         }
         if ($topic['pinned']) {
             $this->pinned_topic_count++;
         }
         $topic_data[$topic['tid']] = $this->renderEntry($topic);
         $total_topics_printed++;
     }
     //-----------------------------------------
     // Finish off the rest of the page  $filter_keys[$topicfilter]))
     //-----------------------------------------
     $sort_by_html = "";
     $sort_key_html = "";
     $prune_day_html = "";
     $filter_html = "";
     foreach ($sort_by_keys as $k => $v) {
         $sort_by_html .= $k == $sort_by ? "<option value='{$k}' selected='selected'>{$this->lang->words[$sort_by_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$sort_by_keys[$k]]}</option>\n";
     }
     foreach ($sort_keys as $k => $v) {
         $sort_key_html .= $k == $sort_key_chk ? "<option value='{$k}' selected='selected'>{$this->lang->words[$sort_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$sort_keys[$k]]}</option>\n";
     }
     foreach ($prune_by_day as $k => $v) {
         $prune_day_html .= $k == $prune_value ? "<option value='{$k}' selected='selected'>{$this->lang->words[$prune_by_day[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$prune_by_day[$k]]}</option>\n";
     }
     foreach ($filter_keys as $k => $v) {
         $filter_html .= $k == $topicfilter ? "<option value='{$k}' selected='selected'>{$this->lang->words[$filter_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$filter_keys[$k]]}</option>\n";
     }
     $footer_filter['sort_by'] = $sort_key_html;
     $footer_filter['sort_order'] = $sort_by_html;
     $footer_filter['sort_prune'] = $prune_day_html;
     $footer_filter['topic_filter'] = $filter_html;
     if ($this->memberData['is_mod']) {
         $count = 0;
         $other_pages = 0;
         if ($this->request['selectedtids'] != "") {
             $tids = explode(",", $this->request['selectedtids']);
             if (is_array($tids) and count($tids)) {
                 foreach ($tids as $tid) {
                     if ($tid != '') {
                         if (!isset($topic_array[$tid])) {
                             $other_pages++;
                         }
                         $count++;
                     }
                 }
             }
         }
         $this->lang->words['f_go'] .= " ({$count})";
         if ($other_pages) {
             $this->lang->words['f_go'] .= " ({$other_pages} " . $this->lang->words['jscript_otherpage'] . ")";
         }
     }
     //-----------------------------------------
     // Multi-moderation?
     //-----------------------------------------
     if ($this->memberData['is_mod']) {
         $mm_array = $this->registry->getClass('class_forums')->getMultimod($this->forum['id']);
         if (is_array($mm_array) and count($mm_array)) {
             foreach ($mm_array as $m) {
                 $multi_mod_data[] = $m;
             }
         }
     }
     //-----------------------------------------
     // Need to update topics?
     //-----------------------------------------
     if (count($this->update_topics_open)) {
         $this->DB->update('topics', array('state' => 'open'), 'tid IN (' . implode(",", $this->update_topics_open) . ')');
     }
     if (count($this->update_topics_close)) {
         $this->DB->update('topics', array('state' => 'closed'), 'tid IN (' . implode(",", $this->update_topics_close) . ')');
     }
     /* Got soft delete tids? */
     if (is_array($this->_sdTids) and count($this->_sdTids)) {
         $other_data['sdData'] = IPSDeleteLog::fetchEntries($this->_sdTids, 'topic', false);
     }
     /* Fetch follow data */
     $other_data['follow_data'] = $this->_like->render('summary', $this->forum['id']);
     return array('announce_data' => $announce_data, 'topic_data' => $topic_data, 'other_data' => $other_data, 'multi_mod_data' => $multi_mod_data, 'footer_filter' => $footer_filter, 'active_users' => $this->_generateActiveUserData());
 }
Ejemplo n.º 25
0
 /**
  * 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);
 }
Ejemplo n.º 26
0
 /**
  * Processes a search request
  *
  * @return	@e void
  */
 public function searchResults()
 {
     /* Search Term */
     if (isset($this->request['search_term']) && !is_string($this->request['search_term'])) {
         $this->registry->getClass('output')->showError('invalid_search_term', 10312564);
     }
     $_st = $this->searchController->formatSearchTerm(trim($this->request['search_term']));
     $search_term = $_st['search_term'];
     $removedTerms = $_st['removed'];
     /* Set up some defaults */
     $this->settings['max_search_word'] = $this->settings['max_search_word'] ? $this->settings['max_search_word'] : 300;
     /* Did we come in off a post request? */
     if ($this->request['request_method'] == 'post') {
         /* Set a no-expires header */
         $this->registry->getClass('output')->setCacheExpirationSeconds(30 * 60);
     }
     if (is_array($this->request['search_app_filters'])) {
         array_walk_recursive($this->request['search_app_filters'], create_function('&$item, $key', '$item = IPSText::htmlspecialchars($item);'));
     }
     /* App specific */
     if (isset($this->request['search_sort_by_' . $this->request['search_app']])) {
         $this->request['search_sort_by'] = $_POST['search_sort_by_' . $this->request['search_app']] ? htmlspecialchars($_POST['search_sort_by_' . $this->request['search_app']]) : $this->request['search_sort_by_' . $this->request['search_app']];
         $this->request['search_sort_order'] = $_POST['search_sort_order_' . $this->request['search_app']] ? htmlspecialchars($_POST['search_sort_order_' . $this->request['search_app']]) : $this->request['search_sort_order_' . $this->request['search_app']];
     }
     /* Populate the registry */
     IPSSearchRegistry::set('in.search_app', $this->request['search_app']);
     IPSSearchRegistry::set('in.raw_search_term', trim($this->request['search_term']));
     IPSSearchRegistry::set('in.clean_search_term', $search_term);
     IPSSearchRegistry::set('in.raw_search_tags', str_replace('&amp;', '&', trim(IPSText::parseCleanValue(IPSText::urldecode_furlSafe($_REQUEST['search_tags'])))));
     IPSSearchRegistry::set('in.search_higlight', str_replace('.', '', $this->request['search_term']));
     IPSSearchRegistry::set('in.search_date_end', ($this->request['search_date_start'] && $this->request['search_date_end'] and !is_array($this->request['search_date_end'])) ? $this->request['search_date_end'] : 'now');
     IPSSearchRegistry::set('in.search_date_start', ($this->request['search_date_start'] and !is_array($this->request['search_date_start'])) ? $this->request['search_date_start'] : '');
     IPSSearchRegistry::set('in.search_author', !empty($this->request['search_author']) ? $this->request['search_author'] : '');
     /* Set sort filters */
     $this->_setSortFilters();
     /* These can be overridden in the actual engine scripts */
     //	IPSSearchRegistry::set('set.hardLimit'        , 0 );
     IPSSearchRegistry::set('set.resultsCutToLimit', false);
     IPSSearchRegistry::set('set.resultsAsForum', false);
     /* Are we option to show titles only / search in titles only */
     IPSSearchRegistry::set('opt.searchType', (!empty($this->request['search_content']) and in_array($this->request['search_content'], array('both', 'titles', 'content'))) ? $this->request['search_content'] : 'both');
     /* Time check */
     if (IPSSearchRegistry::get('in.search_date_start') and strtotime(IPSSearchRegistry::get('in.search_date_start')) > time()) {
         IPSSearchRegistry::set('in.search_date_start', 'now');
     }
     if (IPSSearchRegistry::get('in.search_date_end') and strtotime(IPSSearchRegistry::get('in.search_date_end')) > time()) {
         IPSSearchRegistry::set('in.search_date_end', 'now');
     }
     /* Do some date checking */
     if (IPSSearchRegistry::get('in.search_date_end') and IPSSearchRegistry::get('in.search_date_start') and strtotime(IPSSearchRegistry::get('in.search_date_start')) > strtotime(IPSSearchRegistry::get('in.search_date_end'))) {
         $this->searchAdvancedForm($this->lang->words['search_invalid_date_range']);
         return;
     }
     /**
      * Lower limit
      */
     if ($this->settings['min_search_word'] && !IPSSearchRegistry::get('in.search_author') && !IPSSearchRegistry::get('in.raw_search_tags')) {
         if ($this->settings['search_method'] == 'sphinx' && substr_count($search_term, '"') >= 2) {
             $_ok = true;
         } else {
             $_words = explode(' ', preg_replace("#\"(.*?)\"#", '', $search_term));
             $_ok = $search_term ? true : false;
             foreach ($_words as $_word) {
                 $_word = preg_replace('#^\\+(.+?)$#', "\\1", $_word);
                 if (!$_word or $_word == '|') {
                     continue;
                 }
                 if (strlen($_word) < $this->settings['min_search_word']) {
                     $_ok = false;
                     break;
                 }
             }
         }
         if (!$_ok) {
             $this->searchAdvancedForm(sprintf($this->lang->words['search_term_short'], $this->settings['min_search_word']), $removedTerms);
             return;
         }
     }
     /**
      * Ok this is an upper limit.
      * If you needed to change this, you could do so via conf_global.php by adding:
      * $INFO['max_search_word'] = #####;
      */
     if ($this->settings['max_search_word'] && strlen(IPSSearchRegistry::get('in.raw_search_term')) > $this->settings['max_search_word']) {
         $this->searchAdvancedForm(sprintf($this->lang->words['search_term_long'], $this->settings['max_search_word']));
         return;
     }
     /* Search Flood Check */
     if ($this->memberData['g_search_flood']) {
         /* Check for a cookie */
         $last_search = IPSCookie::get('sfc');
         $last_term = str_replace("&quot;", '"', IPSCookie::get('sfct'));
         $last_term = str_replace("&amp;", '&', $last_term);
         /* If we have a last search time, check it */
         if ($last_search && $last_term) {
             if (time() - $last_search <= $this->memberData['g_search_flood'] && $last_term != IPSSearchRegistry::get('in.raw_search_term')) {
                 $this->searchAdvancedForm(sprintf($this->lang->words['xml_flood'], $this->memberData['g_search_flood'] - (time() - $last_search)));
                 return;
             } else {
                 /* Reset the cookie */
                 IPSCookie::set('sfc', time());
                 IPSCookie::set('sfct', urlencode(IPSSearchRegistry::get('in.raw_search_term')));
             }
         } else {
             IPSCookie::set('sfc', time());
             IPSCookie::set('sfct', urlencode(IPSSearchRegistry::get('in.raw_search_term')));
         }
     }
     /* Clean search term for results view */
     $_search_term = trim(preg_replace('#(^|\\s)(\\+|\\-|\\||\\~)#', " ", $search_term));
     /* Got tag search only but app doesn't support tags */
     if (IPSSearchRegistry::get('in.raw_search_tags') && !IPSSearchRegistry::get('config.can_searchTags') && !IPSSearchRegistry::get('in.raw_search_term')) {
         $count = 0;
         $results = array();
     } else {
         if (IPSLib::appIsSearchable(IPSSearchRegistry::get('in.search_app'), 'search')) {
             /* Perform the search */
             $this->searchController->search();
             /* Get count */
             $count = $this->searchController->getResultCount();
             /* Get results which will be array of IDs */
             $results = $this->searchController->getResultSet();
             /* Get templates to use */
             $template = $this->searchController->fetchTemplates();
             /* Fetch sort details */
             $sortDropDown = $this->searchController->fetchSortDropDown();
             /* Set default sort option */
             $_a = IPSSearchRegistry::get('in.search_app');
             $_k = IPSSearchRegistry::get($_a . '.searchInKey') ? IPSSearchRegistry::get($_a . '.searchInKey') : '';
             if ($_k and !$this->request['search_app_filters'][$_a][$_k]['sortKey'] and is_array($sortDropDown) and count($sortDropDown)) {
                 $this->request['search_app_filters'][$_a][$_k]['sortKey'] = key($sortDropDown);
             } else {
                 if (!$_k and !$this->request['search_app_filters'][$_a]['sortKey'] and is_array($sortDropDown) and count($sortDropDown)) {
                     $this->request['search_app_filters'][$_a]['sortKey'] = key($sortDropDown);
                 }
             }
             /* Fetch sort details */
             $sortIn = $this->searchController->fetchSortIn();
             /* Build pagination */
             $links = $this->registry->output->generatePagination(array('totalItems' => $count, 'itemsPerPage' => IPSSearchRegistry::get('opt.search_per_page'), 'currentStartValue' => IPSSearchRegistry::get('in.start'), 'baseUrl' => $this->_buildURLString() . '&amp;search_app=' . IPSSearchRegistry::get('in.search_app')));
             /* Showing */
             $showing = array('start' => IPSSearchRegistry::get('in.start') + 1, 'end' => IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page') > $count ? $count : IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page'));
             /* Parse result set */
             $results = $this->registry->output->getTemplate($template['group'])->{$template}['template']($results, IPSSearchRegistry::get('opt.searchType') == 'titles' || IPSSearchRegistry::get('opt.noPostPreview') ? 1 : 0);
             /* Check for sortIn */
             if (count($sortIn) && !$this->request['search_app_filters'][$this->request['search_app']]['searchInKey']) {
                 $this->request['search_app_filters'][$this->request['search_app']]['searchInKey'] = $sortIn[0][0];
             }
         } else {
             $count = 0;
             $results = array();
         }
     }
     if ($count < 1) {
         $this->registry->output->setHeaderCode(404);
     }
     /* Output */
     $this->title = $this->lang->words['search_results'];
     $this->output .= $this->registry->output->getTemplate('search')->searchResultsWrapper($results, $sortDropDown, $sortIn, $links, $count, $showing, $_search_term, $this->_buildURLString(), $this->request['search_app'], $removedTerms, IPSSearchRegistry::get('set.hardLimit'), IPSSearchRegistry::get('set.resultsCutToLimit'), IPSSearchRegistry::get('in.raw_search_tags'));
 }
Ejemplo n.º 27
0
 /**
  * Process Logout
  *
  * @param	int		ID number
  * @param	string	md5( IPS Connect Key (see login method) . ID number )
  * @param	string	Redirect URL, Base64 encoded
  * @param	string	md5( IPS Connect Key . $redirect )
  * @return	mixed	If the redirect URL is provided, this function should redirect the user to that URL
  *					If blank, will output blank screen
  */
 public function logout($id, $key, $redirect, $redirectHash)
 {
     if ($key != md5($this->masterKey . $id)) {
         $this->_return(base64_encode($this->settings['board_url']));
     }
     IPSCookie::set("ipsconnect_" . md5($this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php'), '0', 1, 0, FALSE, FALSE);
     $member = IPSMember::load(intval($id), 'none', 'id');
     if ($member['member_id']) {
         IPSCookie::set("member_id", "0");
         IPSCookie::set("pass_hash", "0");
         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);
                 }
             }
         }
         $this->member->sessionClass()->convertMemberToGuest();
         $privacy = intval(IPSMember::isLoggedInAnon($member));
         IPSMember::save($member['member_id'], array('core' => array('login_anonymous' => "{$privacy}&0", 'last_activity' => IPS_UNIX_TIME_NOW)));
         IPSLib::runMemberSync('onLogOut', $member);
         $this->han_login->logoutCallback($member);
         /* Run any custom code */
         $this->_runCustom('logout', array($member));
     }
     if ($redirect) {
         $redirect = $redirectHash == md5($this->masterKey . $redirect) ? $redirect : base64_encode($this->settings['board_url']);
     }
     $this->_return($redirect);
 }
 /**
  * Constructor
  * 
  * @access	public
  * @param	string	[$lang]		Language file to load, english by default
  * @return	void
  */
 public function __construct(ipsRegistry $registry)
 {
     /* Make objects */
     $this->DB = $registry->DB();
     $this->settings = $registry->fetchSettings();
     $this->member = $registry->member();
     $this->cache = $registry->cache();
     $this->caches =& $registry->cache()->fetchCaches();
     $this->request = $registry->fetchRequest();
     $this->memberData =& $registry->member()->fetchMemberData();
     /* Rebuild the cache if needed */
     if (!$this->caches['lang_data']) {
         $this->rebuildLanguagesCache();
     }
     /* Find the lang we need */
     if ($this->caches['lang_data']) {
         foreach ($this->caches['lang_data'] as $_lang) {
             $this->languages[] = $_lang;
             if ($_lang['lang_default']) {
                 $this->local = $_lang['lang_short'];
                 $this->lang_id = $_lang['lang_id'];
                 $this->language_dir = $_lang['lang_id'];
                 /* Guests get the default */
                 if (!$this->memberData['member_id']) {
                     $this->member->language_id = $this->lang_id;
                 }
             }
         }
     }
     /* Got a guest cookie? */
     if (!$this->memberData['member_id']) {
         $langCookie = IPSCookie::get('language');
         if ($langCookie) {
             $this->member->language_id = trim(IPSText::parseCleanValue($langCookie));
         }
     }
     /* Forcing Engrish? */
     if ($forceCookie = IPSCookie::get('forceEnglish')) {
         if ($forceCookie) {
             $this->_forceEnglish = true;
         }
     }
     //-----------------------------------------
     // Time options
     //-----------------------------------------
     /* 	%b is month abbr
     			%B is full month
     			%d is date 01-31
     			%Y is 4 digit year
     			%g is 2 digit year
     			%I is hour 01-12
     			%H - hour as a decimal number using a 24-hour clock (range 00 to 23) 
     			%M is min 01-59
     			%p is am/pm */
     $this->time_options = array('JOINED' => $this->settings['clock_joined'] ? $this->settings['clock_joined'] : '%d-%B %y', 'SHORT' => $this->settings['clock_short'] ? $this->settings['clock_short'] : '%b %d %Y %I:%M %p', 'LONG' => $this->settings['clock_long'] ? $this->settings['clock_long'] : '%d %B %Y - %I:%M %p', 'TINY' => $this->settings['clock_tiny'] ? $this->settings['clock_tiny'] : '%d %b %Y - %H:%M', 'DATE' => $this->settings['clock_date'] ? $this->settings['clock_date'] : '%d %b %Y', 'TIME' => 'h:i A', 'ACP' => '%d %B %Y, %H:%M', 'ACP2' => '%d %B %Y, %H:%M');
     //--------------------------------
     // Did we choose a language?
     //--------------------------------
     if (isset($this->request['setlanguage']) and $this->request['setlanguage'] and $this->request['langid']) {
         /* Forcing english? */
         if ($this->request['langid'] == '__english__') {
             IPSDebug::addMessage("forceEnglish cookie written");
             IPSCookie::set('forceEnglish', 1, 0);
             $this->_forceEnglish = true;
         } else {
             if ($this->request['k'] == $this->member->form_hash and is_array(ipsRegistry::cache()->getCache('lang_data')) and count(ipsRegistry::cache()->getCache('lang_data'))) {
                 foreach (ipsRegistry::cache()->getCache('lang_data') as $data) {
                     if ($data['lang_id'] == $this->request['langid']) {
                         if ($this->memberData['member_id']) {
                             IPSMember::save($this->memberData['member_id'], array('core' => array('language' => $data['lang_id'])));
                         } else {
                             IPSCookie::set('language', $data['lang_id']);
                         }
                         $this->member->language_id = $data['lang_id'];
                         $this->member->setProperty('language', $data['lang_id']);
                         break;
                     }
                 }
             }
         }
     }
     //--------------------------------
     // Now set it
     //--------------------------------
     if ($this->member->language_id) {
         foreach ($this->caches['lang_data'] as $_lang) {
             if ($_lang['lang_id'] == $this->member->language_id) {
                 $this->local = $_lang['lang_short'];
                 $this->lang_id = $_lang['lang_id'];
                 $this->language_dir = $_lang['lang_id'];
                 break;
             }
         }
     }
     //-----------------------------------------
     // Set locale
     //-----------------------------------------
     setlocale(LC_ALL, $this->local);
     $this->local_data = localeconv();
     //-----------------------------------------
     // Using in_dev override
     //-----------------------------------------
     if (IN_DEV and !$this->_forceEnglish) {
         if (is_dir(IPS_CACHE_PATH . 'cache/lang_cache/master_lang')) {
             $this->lang_id = 'master_lang';
         }
     }
 }
 /**
  * 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;
 }
 /**
  * Log the user out
  *
  * @access	public
  * @return	void
  */
 public function loginOut()
 {
     //-----------------------------------------
     // Do it..
     //-----------------------------------------
     $this->DB->delete('core_sys_cp_sessions', "session_id='" . $this->request['adsess'] . "'");
     //-----------------------------------------
     // Bash cookie
     //-----------------------------------------
     IPSCookie::set("ipb3AcpSessionId", 'x', -1);
     //-----------------------------------------
     // Redirect...
     //-----------------------------------------
     ipsRegistry::getClass('output')->redirect($this->settings['base_url'] . '/' . CP_DIRECTORY . '/index.php', $this->lang->words['logout_complete']);
 }