Пример #1
0
 /**
  * Singleton init method
  *
  * @return	@e void
  */
 protected static function init()
 {
     if (self::$initiated !== TRUE) {
         //-----------------------------------------
         // IP Address
         //-----------------------------------------
         if (ipsRegistry::$settings['xforward_matching']) {
             //foreach( array_reverse( explode( ',', my_getenv('HTTP_X_FORWARDED_FOR') ) ) as $x_f ) // See http://community.invisionpower.com/resources/bugs.html/_/ip-board/multiple-ips-in-x-forwarded-for-r37844
             foreach (explode(',', my_getenv('HTTP_X_FORWARDED_FOR')) as $x_f) {
                 $addrs[] = trim($x_f);
             }
             $addrs[] = my_getenv('HTTP_CLIENT_IP');
             $addrs[] = my_getenv('HTTP_X_CLUSTER_CLIENT_IP');
             $addrs[] = my_getenv('HTTP_PROXY_USER');
         }
         $addrs[] = my_getenv('REMOTE_ADDR');
         //-----------------------------------------
         // Do we have one yet?
         //-----------------------------------------
         foreach ($addrs as $ip) {
             //-----------------------------------------
             // IP v4
             //-----------------------------------------
             if (IPSLib::validateIPv4($ip)) {
                 self::instance()->ip_address = $ip;
                 break;
             } else {
                 if (IPSLib::validateIPv6($ip)) {
                     self::instance()->ip_address = $ip;
                     break;
                 }
             }
         }
         //-----------------------------------------
         // Make sure we take a valid IP address
         //-----------------------------------------
         if (!self::instance()->ip_address and !isset($_SERVER['SHELL']) and $_SERVER['SESSIONNAME'] != 'Console') {
             if (!defined('IPS_IS_SHELL') or !IPS_IS_SHELL) {
                 print "Could not determine your IP address";
                 exit;
             }
         }
         //-----------------------------------------
         // Get user-agent, browser and OS
         //-----------------------------------------
         self::instance()->user_agent = IPSText::parseCleanValue(my_getenv('HTTP_USER_AGENT'));
         self::instance()->operating_system = self::_fetch_os();
         if (IPS_AREA == 'admin') {
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/session/adminSessions.php', 'adminSessions');
             /**
              * Support for extending the session class
              */
             if (is_file(IPS_ROOT_PATH . "sources/classes/session/ssoAdminSessions.php")) {
                 $classToLoadA = IPSLib::loadLibrary(IPS_ROOT_PATH . "sources/classes/session/ssoAdminSessions.php", 'ssoAdminSessions');
                 /**
                  * Does the ssoAdminSessions class exist?
                  */
                 if (class_exists($classToLoadA)) {
                     $parent = get_parent_class($classToLoadA);
                     /**
                      * Is it a child of adminSessions
                      */
                     if ($parent == $classToLoad) {
                         self::$session_class = new $classToLoadA();
                     } else {
                         self::$session_class = new $classToLoad();
                     }
                 }
             } else {
                 self::$session_class = new $classToLoad();
             }
         } else {
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/session/publicSessions.php', 'publicSessions');
             /**
              * Support for extending the session class
              */
             if (is_file(IPS_ROOT_PATH . "sources/classes/session/ssoPublicSessions.php")) {
                 $classToLoadA = IPSLib::loadLibrary(IPS_ROOT_PATH . "sources/classes/session/ssoPublicSessions.php", 'ssoPublicSessions');
                 /**
                  * Does the ssoPublicSessions class exist?
                  */
                 if (class_exists($classToLoadA)) {
                     $parent = get_parent_class($classToLoadA);
                     /**
                      * Is it a child of publicSessions
                      */
                     if ($parent == $classToLoad) {
                         self::$session_class = new $classToLoadA();
                     } else {
                         self::$session_class = new $classToLoad();
                     }
                 }
             } else {
                 self::$session_class = new $classToLoad();
             }
             //-----------------------------------------
             // Set other
             //-----------------------------------------
             self::$data_store['publicSessionID'] = self::$session_class->session_data['id'];
         }
         //-----------------------------------------
         // Set user agent
         //-----------------------------------------
         $_cookie = IPSCookie::get("uagent_bypass");
         self::$data_store['userAgentKey'] = isset(self::$session_class->session_data['uagent_key']) ? self::$session_class->session_data['uagent_key'] : '';
         self::$data_store['userAgentType'] = isset(self::$data_store['uagent_type']) ? self::$data_store['uagent_type'] : self::$session_class->session_data['uagent_type'];
         self::$data_store['userAgentVersion'] = isset(self::$session_class->session_data['uagent_version']) ? self::$session_class->session_data['uagent_version'] : '';
         self::$data_store['userAgentBypass'] = $_cookie ? true : (isset(self::$session_class->session_data['uagent_bypass']) ? self::$session_class->session_data['uagent_bypass'] : '');
         self::$data_store['forumsModeratorData'] = array();
         /* Some mobile app set up */
         if (self::$data_store['userAgentType'] == 'mobileApp') {
             /* This converts non UTF-8 POST/GET data in __construct */
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . '/sources/base/ipsMobileApp.php', 'ipsMobileApp');
             ipsRegistry::setClass('isMobileApp', new $classToLoad());
         }
     }
 }
Пример #2
0
 /**
  * Authorize
  *
  * @access	public
  * @return	@e void
  */
 public function __construct()
 {
     /* Make object */
     $this->registry = ipsRegistry::instance();
     $this->DB = $this->registry->DB();
     $this->settings =& $this->registry->fetchSettings();
     $this->request =& $this->registry->fetchRequest();
     //--------------------------------------------
     // Got a cookie wookey?
     //--------------------------------------------
     $_adsess = ipsRegistry::$request['adsess'];
     $_time_out_mins = defined('IPB_ACP_SESSION_TIME_OUT') ? IPB_ACP_SESSION_TIME_OUT : 60;
     //-----------------------------------------
     // If the cookie doesn't match URL... use URL?
     //-----------------------------------------
     if ($_adsess) {
         $this->session_type = 'url';
         ipsRegistry::$request['adsess'] = $_adsess;
     }
     //--------------------------------------------
     // Continue...
     //--------------------------------------------
     if (!ipsRegistry::$request['adsess']) {
         //--------------------------------------------
         // No URL adsess found, lets log in.
         //--------------------------------------------
         return $this->_response(0, '');
     } else {
         //--------------------------------------------
         // We have a URL adsess, lets verify...
         //--------------------------------------------
         $this->DB->build(array('select' => '*', 'from' => 'core_sys_cp_sessions', 'where' => "session_id='" . IPSText::md5clean(ipsRegistry::$request['adsess']) . "'"));
         $this->DB->execute();
         $session_data = $this->DB->fetch();
         $_tab_data = unserialize($session_data['session_app_data']);
         $_tab_data = is_array($_tab_data) ? $_tab_data : array();
         if ($session_data['session_id'] == "") {
             //--------------------------------------------
             // Fail-safe, no DB record found, lets log in..
             //--------------------------------------------
             return $this->_response(0, '');
         } else {
             if ($session_data['session_member_id'] == "") {
                 //--------------------------------------------
                 // No member ID is stored, log in!
                 //--------------------------------------------
                 return $this->_response(0, 'session_nomemberid');
             } else {
                 //--------------------------------------------
                 // Key is good, check the member details
                 //--------------------------------------------
                 $this->DB->build(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => "member_id=" . intval($session_data['session_member_id']), 'add_join' => array(0 => array('select' => 'g.*', 'from' => array('groups' => 'g'), 'where' => 'm.member_group_id=g.g_id', 'type' => 'left'), 1 => array('select' => 's.*', 'from' => array('core_sys_login' => 's'), 'where' => 's.sys_login_id = m.member_id', 'type' => 'left'))));
                 $this->DB->execute();
                 self::$data_store = $this->DB->fetch();
                 self::$data_store = self::instance()->setUpSecondaryGroups(self::$data_store);
                 //--------------------------------------------
                 // Get perms
                 //--------------------------------------------
                 if (self::$data_store['member_id'] == "") {
                     //--------------------------------------------
                     // Ut-oh, no such member, log in!
                     //--------------------------------------------
                     return $this->_response(0, 'session_invalidmid');
                 } else {
                     //--------------------------------------------
                     // Member found, check passy
                     //--------------------------------------------
                     //if ( $session_data['session_member_login_key'] != self::$data_store['member_login_key'] )
                     //{
                     //	//--------------------------------------------
                     //	// Passys don't match..
                     //	//--------------------------------------------
                     //
                     //	return $this->_response( 0, 'Session member password mismatch' );
                     //}
                     //else
                     //{
                     //--------------------------------------------
                     // Do we have admin access?
                     //--------------------------------------------
                     if (self::$data_store['g_access_cp'] != 1) {
                         return $this->_response(0, 'session_noaccess');
                     } else {
                         $this->_validated = TRUE;
                     }
                     //}
                 }
             }
         }
     }
     //--------------------------------------------
     // If we're here, we're valid...
     //--------------------------------------------
     if ($this->_validated === TRUE) {
         if ($session_data['session_running_time'] < time() - $_time_out_mins * 60) {
             self::$data_store = array();
             self::setMember(0);
             $this->_validated = FALSE;
             return $this->_response(0, 'session_timeout');
         } else {
             if (IPB_ACP_IP_MATCH) {
                 if ($session_data['session_ip_address'] != self::instance()->ip_address or !IPSLib::validateIPv4($session_data['session_ip_address']) and !IPSLib::validateIPv6($session_data['session_ip_address']) or !IPSLib::validateIPv4(self::instance()->ip_address) and !IPSLib::validateIPv6(self::instance()->ip_address)) {
                     self::$data_store = array();
                     self::setMember(0);
                     $this->_validated = FALSE;
                     return $this->_response(0, 'session_mismatchip');
                 }
             }
         }
         self::setMember(self::$data_store['member_id']);
         //-----------------------------------------
         // Fix up secondary groups
         //-----------------------------------------
         if (self::$data_store['mgroup_others']) {
             $groups_id = explode(',', self::$data_store['mgroup_others']);
             $masks = array();
             $cache = ipsRegistry::cache()->getCache('group_cache');
             if (count($groups_id)) {
                 foreach ($groups_id as $pid) {
                     if (empty($cache[$pid]['g_id'])) {
                         continue;
                     }
                     //-----------------------------------------
                     // Got masks?
                     //-----------------------------------------
                     if ($cache[$pid]['g_perm_id']) {
                         self::$data_store['g_perm_id'] .= ',' . $cache[$pid]['g_perm_id'];
                     }
                 }
             }
         }
         //-----------------------------------------
         // Current Location, used for online list
         //-----------------------------------------
         $module = ipsRegistry::$request['module'] != 'ajax' ? ipsRegistry::$request['module'] : $session_data['session_location'];
         $location = $session_data['session_url'];
         if (IPS_APP_COMPONENT && ipsRegistry::$request['module'] != 'ajax') {
             $location = str_ireplace("login=yes", "", ipsRegistry::$settings['query_string_safe']);
             $location = ltrim($location, '?');
             $location = preg_replace("!adsess=(\\w){32}!", "", $location);
             $location = preg_replace("!&mshow=(.+?)*!i", "", $location);
             $location = preg_replace("!&st=(.+?)*!i", "", $location);
             $location = preg_replace("!&messageinabottleacp=(.+?)*!i", "", $location);
         }
         /* Compare user-agent stuff */
         $session_data['_session_app_data'] = unserialize($session_data['session_app_data']);
         if (is_array($session_data['_session_app_data']) and $session_data['_session_app_data']['uagent_key']) {
             if ($session_data['_session_app_data']['uagent_raw'] != self::instance()->user_agent) {
                 $session_data['_session_app_data'] = self::_processUserAgent();
                 $session_data['_session_app_data']['uagent_raw'] = self::instance()->user_agent;
             }
         } else {
             $session_data['_session_app_data'] = self::_processUserAgent();
             $session_data['_session_app_data']['uagent_raw'] = self::instance()->user_agent;
         }
         //-----------------------------------------
         // Done...
         //-----------------------------------------
         $this->DB->update('core_sys_cp_sessions', array('session_running_time' => time(), 'session_location' => $module, 'session_url' => $location, 'session_app_data' => serialize($session_data['_session_app_data']), 'session_member_name' => self::$data_store['members_display_name']), 'session_member_id=' . intval(self::$data_store['member_id']) . " and session_id='" . ipsRegistry::$request['adsess'] . "'");
         return $this->_response(1, '', $session_data['_session_app_data']);
     }
 }
 /**
  * Our singleton INIT function
  *
  * @access	protected
  * @return	@e void
  */
 protected static function init()
 {
     if (self::$initiated !== TRUE) {
         //-----------------------------------------
         // IP Address
         //-----------------------------------------
         if (ipsRegistry::$settings['xforward_matching']) {
             foreach (array_reverse(explode(',', my_getenv('HTTP_X_FORWARDED_FOR'))) as $x_f) {
                 $addrs[] = trim($x_f);
             }
             $addrs[] = my_getenv('HTTP_CLIENT_IP');
             $addrs[] = my_getenv('HTTP_X_CLUSTER_CLIENT_IP');
             $addrs[] = my_getenv('HTTP_PROXY_USER');
         }
         $addrs[] = my_getenv('REMOTE_ADDR');
         //-----------------------------------------
         // Do we have one yet?
         //-----------------------------------------
         foreach ($addrs as $ip) {
             //-----------------------------------------
             // IP v4
             //-----------------------------------------
             if (IPSLib::validateIPv4($ip)) {
                 self::instance()->ip_address = $ip;
                 break;
             } else {
                 if (IPSLib::validateIPv6($ip)) {
                     self::instance()->ip_address = $ip;
                     break;
                 }
             }
         }
         //-----------------------------------------
         // Make sure we take a valid IP address
         //-----------------------------------------
         if (!self::instance()->ip_address and !isset($_SERVER['SHELL']) and $_SERVER['SESSIONNAME'] != 'Console') {
             print "Could not determine your IP address";
             exit;
         }
         if (IPS_IS_UPGRADER) {
             require_once IPS_ROOT_PATH . "setup/sources/classes/session/sessions.php";
             /*noLibHook*/
             self::$session_class = new sessions();
         } else {
             self::setMember(0);
         }
     }
 }
Пример #4
0
 /**
  * Set a cookie.
  *
  * Abstract layer allows us to do some checking, etc
  *
  * @param	string		Cookie name
  * @param	string		Cookie value
  * @param	integer		Is sticky flag
  * @param	integer		Number of days to expire cookie in
  * @param	bool		If false, will set a cookie on the entire domain
  * @param	bool		If $local is false, controls if the cookie prefix should be used
  * @return	@e void
  * @since	2.0
  */
 public static function set($name, $value = "", $sticky = 1, $expires_x_days = 0, $local = TRUE, $usePrefix = FALSE)
 {
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if (!empty(ipsRegistry::$settings['no_print_header'])) {
         return;
     }
     /* Update internal array */
     self::$_cookiesSet[$name] = $value;
     //-----------------------------------------
     // Auto serialize arrays
     //-----------------------------------------
     if (is_array($value)) {
         $value = json_encode($value);
     }
     //-----------------------------------------
     // Set vars
     //-----------------------------------------
     if ($sticky == 1) {
         $expires = time() + 60 * 60 * 24 * 365;
     } else {
         if ($expires_x_days) {
             $expires = time() + $expires_x_days * 86400;
         } else {
             $expires = FALSE;
         }
     }
     //-----------------------------------------
     // Finish up...
     //-----------------------------------------
     ipsRegistry::$settings['cookie_domain'] = ipsRegistry::$settings['cookie_domain'] == "" ? "" : ipsRegistry::$settings['cookie_domain'];
     ipsRegistry::$settings['cookie_path'] = ipsRegistry::$settings['cookie_path'] == "" ? "/" : ipsRegistry::$settings['cookie_path'];
     $_name = (($local or $usePrefix) ? ipsRegistry::$settings['cookie_id'] : '') . $name;
     $_path = $local ? ipsRegistry::$settings['cookie_path'] : '/';
     if ($local or substr(ipsRegistry::$settings['cookie_domain'], 0, 1) === '.') {
         $_domain = ipsRegistry::$settings['cookie_domain'];
     } else {
         $parsedUrl = parse_url(ipsRegistry::$settings['board_url']);
         /* Test to make sure we're not using an IP address or hostname (such as localhost, etc) */
         if (!strstr($parsedUrl['host'], '.') || IPSLib::validateIPv4($parsedUrl['host']) || IPSLib::validateIPv4($parsedUrl['host'])) {
             $_domain = '';
         } else {
             $_domain = array();
             foreach (array_reverse(explode('.', $parsedUrl['host'])) as $bit) {
                 $_domain[] = $bit;
                 if (!in_array($bit, array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bl', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'eh', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm', 'zw'))) {
                     break;
                 }
             }
             $_domain = '.' . implode('.', array_reverse($_domain));
         }
     }
     //-----------------------------------------
     // Set the cookie
     //-----------------------------------------
     if (in_array($name, self::$sensitive_cookies)) {
         if (PHP_VERSION < 5.2) {
             if (ipsRegistry::$settings['cookie_domain']) {
                 @setcookie($_name, $value, $expires, $_path, $_domain . '; HttpOnly');
             } else {
                 @setcookie($_name, $value, $expires, $_path);
             }
         } else {
             @setcookie($_name, $value, $expires, $_path, $_domain, NULL, TRUE);
         }
     } else {
         @setcookie($_name, $value, $expires, $_path, $_domain);
     }
 }
Пример #5
0
 /**
  * Authenticate the request
  *
  * @access	public
  * @param	string		Username
  * @param	string		Email Address
  * @param	string		Password
  * @return	boolean		Authentication successful
  */
 public function authenticate($username, $email_address, $password)
 {
     //-----------------------------------------
     // Set basic data
     //-----------------------------------------
     $send = array('act' => 'login', 'key' => $this->connectConfig['master_key'], 'password' => md5($password));
     //-----------------------------------------
     // Load to check if we have master ID already
     //-----------------------------------------
     if ($username) {
         $_member = IPSMember::load($username, 'all', 'username');
     } else {
         $_member = IPSMember::load($email_address, 'all', 'email');
     }
     if ($_member['ipsconnect_id']) {
         $send['idType'] = 'id';
         $send['id'] = $_member['ipsconnect_id'];
     } else {
         if ($username) {
             $send['idType'] = 'username';
             $send['id'] = $username;
         } else {
             $send['idType'] = 'email';
             $send['id'] = $email_address;
         }
     }
     //-----------------------------------------
     // Send API Call
     //-----------------------------------------
     $send['key'] = md5($send['key'] . $send['id']);
     $url = $this->connectConfig['master_url'] . '?' . http_build_query($send);
     $return = $this->cfm->getFileContents($url);
     $data = @json_decode($return, TRUE);
     if (!isset($data['connect_status']) or !$data['connect_status']) {
         $this->return_code = 'WRONG_AUTH';
         return false;
     }
     //-----------------------------------------
     // If unsuccessful, return
     //-----------------------------------------
     if ($data['connect_status'] != 'SUCCESS') {
         $this->return_code = $data['connect_status'];
         if ($this->return_code == 'ACCOUNT_LOCKED') {
             $this->account_unlock = $data['connect_unlock'];
             /* @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/ipsconnect-account-unlock-time-r40812 */
             if ($data['connect_unlock_period']) {
                 $this->settings['ipb_bruteforce_period'] = $data['connect_unlock_period'];
             }
         }
         if ($this->return_code == 'VALIDATING') {
             $this->revalidate_url = $data['connect_revalidate_url'];
         }
         return false;
     }
     //-----------------------------------------
     // Create or update member accordingly
     //-----------------------------------------
     $update = array();
     $this->member_data = IPSMember::load($data['connect_id'], 'all', 'ipsconnect');
     if (!isset($this->member_data['member_id']) and isset($_member['member_id'])) {
         $this->member_data = $_member;
         $update['ipsconnect_id'] = $data['connect_id'];
     }
     if (!isset($this->member_data['member_id'])) {
         if (IPSText::mbstrlen($data['connect_username']) > ipsRegistry::$settings['max_user_name_length']) {
             $data['connect_username'] = IPSText::mbsubstr($data['connect_username'], 0, ipsRegistry::$settings['max_user_name_length']);
         }
         $this->member_data = $this->createLocalMember(array('members' => array('name' => $data['connect_username'], 'members_display_name' => $data['connect_displayname'], 'email' => $email_address, 'password' => $password, 'ipsconnect_id' => $data['connect_id'])));
     } else {
         if ($this->member_data['name'] != $data['connect_username'] and !defined('CONNECT_NOSYNC_NAMES')) {
             $update['name'] = $data['connect_username'];
         }
         if ($this->member_data['members_display_name'] != $data['connect_displayname'] and !defined('CONNECT_NOSYNC_NAMES')) {
             $update['members_display_name'] = $data['connect_displayname'];
         }
         if ($this->member_data['email'] != $data['connect_email']) {
             $update['email'] = $data['connect_email'];
         }
         IPSMember::updatePassword($this->member_data['member_id'], md5($password));
     }
     //-----------------------------------------
     // Privacy
     //-----------------------------------------
     $privacy = $this->member_data['g_hide_online_list'] || empty($this->settings['disable_anonymous']) && !empty($this->request['anonymous']) ? 1 : 0;
     $update['login_anonymous'] = intval($privacy) . '&1';
     //-----------------------------------------
     // Update
     //-----------------------------------------
     if (!empty($update)) {
         IPSMember::save($this->member_data['member_id'], array('members' => $update));
     }
     //-----------------------------------------
     // If this is ACP or cross domain, just log in without SSO
     // http://community.invisionpower.com/resources/bugs.html/_/ip-board/cross-domain-connect-logins-r41932
     //-----------------------------------------
     $local = strtolower(@parse_url($this->settings['board_url'], PHP_URL_HOST));
     $connect = strtolower(@parse_url($this->connectConfig['master_url'], PHP_URL_HOST));
     if (strstr($local, '.') && !IPSLib::validateIPv4($local)) {
         $_domain = array();
         foreach (array_reverse(explode('.', $local)) as $bit) {
             $_domain[] = $bit;
             if (!in_array($bit, array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bl', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'eh', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm', 'zw'))) {
                 break;
             }
         }
         $local = '.' . implode('.', array_reverse($_domain));
     }
     if (strstr($connect, '.') && !IPSLib::validateIPv4($connect)) {
         $_domain = array();
         foreach (array_reverse(explode('.', $connect)) as $bit) {
             $_domain[] = $bit;
             if (!in_array($bit, array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bl', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'eh', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm', 'zw'))) {
                 break;
             }
         }
         $connect = '.' . implode('.', array_reverse($_domain));
     }
     if ($this->is_admin_auth or $this->is_password_check or $local != $connect) {
         $this->return_code = 'SUCCESS';
         return;
     }
     //-----------------------------------------
     // And redirect to log us in centrally
     //-----------------------------------------
     $redirect = $this->request['referer'] ? $this->request['referer'] : $this->settings['board_url'];
     if (strpos($redirect, '?') === FALSE) {
         $redirect .= '?';
     }
     $this->registry->output->silentRedirect($url . '&noparams=1&redirect=' . base64_encode($redirect) . '&redirectHash=' . md5($this->connectConfig['master_key'] . base64_encode($redirect)));
 }