Пример #1
0
 /**
  *	Handles setting adding a newly created session to the request object
  *
  * 	Adds the session to the request
  *	Sets the session language to the request langauge if we have one
  *	Registers the session with the vB class
  *
  *	@param vB_Session $session
  */
 protected function setSession($session)
 {
     $this->session = $session;
     if ($this->languageid) {
         $this->session->set('languageid', $this->languageid);
     }
     vB::setCurrentSession($this->session);
 }
Пример #2
0
function process_logout()
{
	global $vbulletin;

	// clear all cookies beginning with COOKIE_PREFIX
	$prefix_length = strlen(COOKIE_PREFIX);
	foreach ($_COOKIE AS $key => $val)
	{
		$index = strpos($key, COOKIE_PREFIX);
		if ($index == 0 AND $index !== false)
		{
			$key = substr($key, $prefix_length);
			if (trim($key) == '')
			{
				continue;
			}
			// vbsetcookie will add the cookie prefix
			vbsetcookie($key, '', 1);
		}
	}

	if ($vbulletin->userinfo['userid'] AND $vbulletin->userinfo['userid'] != -1)
	{
		// init user data manager
		$userdata =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
		$userdata->set_existing($vbulletin->userinfo);
		$userdata->set('lastactivity', TIMENOW - $vbulletin->options['cookietimeout']);
		$userdata->set('lastvisit', TIMENOW);
		$userdata->save();

		// make sure any other of this user's sessions are deleted (in case they ended up with more than one)
		$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "session WHERE userid = " . $vbulletin->userinfo['userid']);
	}

	$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "session WHERE sessionhash = '" . $vbulletin->db->escape_string($vbulletin->session->vars['dbsessionhash']) . "'");

	if ($vbulletin->session->created == true)
	{
		// if we just created a session on this page, there's no reason not to use it
		$newsession = $vbulletin->session;
	}
	else
	{
		$newsession = new vB_Session($vbulletin, '', 0, '', $vbulletin->session->vars['styleid']);
	}
	$newsession->set('userid', 0);
	$newsession->set('loggedin', 0);
	$newsession->set_session_visibility(($vbulletin->superglobal_size['_COOKIE'] > 0));
	$vbulletin->session =& $newsession;

	($hook = vBulletinHook::fetch_hook('logout_process')) ? eval($hook) : false;
}
Пример #3
0
function process_logout()
{
    global $vbulletin;
    // clear all cookies beginning with COOKIE_PREFIX
    $prefix_length = strlen(COOKIE_PREFIX);
    foreach ($_COOKIE as $key => $val) {
        $index = strpos($key, COOKIE_PREFIX);
        if ($index == 0 and $index !== false) {
            $key = substr($key, $prefix_length);
            if (trim($key) == '') {
                continue;
            }
            // vbsetcookie will add the cookie prefix
            vbsetcookie($key, '', 1);
        }
    }
    if ($vbulletin->userinfo['userid'] and $vbulletin->userinfo['userid'] != -1) {
        // init user data manager
        $userdata =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
        $userdata->set_existing($vbulletin->userinfo);
        $userdata->set('lastactivity', TIMENOW - $vbulletin->options['cookietimeout']);
        $userdata->set('lastvisit', TIMENOW);
        $userdata->save();
        // make sure any other of this user's sessions are deleted (in case they ended up with more than one)
        $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "session WHERE userid = " . $vbulletin->userinfo['userid']);
    }
    $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "session WHERE sessionhash = '" . $vbulletin->db->escape_string($vbulletin->session->vars['dbsessionhash']) . "'");
    // Remove accesstoken from apiclient table so that a new one will be generated
    if (defined('VB_API') and VB_API === true and $vbulletin->apiclient['apiclientid']) {
        $vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "apiclient SET apiaccesstoken = '', userid = 0\n\t\t\tWHERE apiclientid = " . intval($vbulletin->apiclient['apiclientid']));
        $vbulletin->apiclient['apiaccesstoken'] = '';
    }
    if ($vbulletin->session->created == true and !VB_API) {
        // if we just created a session on this page, there's no reason not to use it
        $newsession = $vbulletin->session;
    } else {
        // API should always create a new session here to generate a new accesstoken
        $newsession = new vB_Session($vbulletin, '', 0, '', $vbulletin->session->vars['styleid']);
    }
    $newsession->set('userid', 0);
    $newsession->set('loggedin', 0);
    $newsession->set_session_visibility($vbulletin->superglobal_size['_COOKIE'] > 0);
    $vbulletin->session =& $newsession;
    ($hook = vBulletinHook::fetch_hook('logout_process')) ? eval($hook) : false;
}