Vergleich inc/class_session.php - 1.8.22 - 1.8.23

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 34Zeile 34
	 * @var bool
*/
public $is_spider = false;

	 * @var bool
*/
public $is_spider = false;

 

/**
* Request parameters that are to be ignored for location storage
*
* @var array
*/
public $ignore_parameters = array(
'my_post_key',
'logoutkey',
);


/**
* Initialize a session
*/
function init()
{


/**
* Initialize a session
*/
function init()
{

		global $db, $mybb, $cache;

		global $db, $mybb, $cache, $plugins;


// Get our visitor's IP.
$this->ipaddress = get_ip();


// Get our visitor's IP.
$this->ipaddress = get_ip();

Zeile 51Zeile 61

// Attempt to find a session id in the cookies.
if(isset($mybb->cookies['sid']) && !defined('IN_UPGRADE'))


// Attempt to find a session id in the cookies.
if(isset($mybb->cookies['sid']) && !defined('IN_UPGRADE'))

		{

		{

			$sid = $db->escape_string($mybb->cookies['sid']);

			$sid = $db->escape_string($mybb->cookies['sid']);

			// Load the session
$query = $db->simple_select("sessions", "*", "sid='{$sid}' AND ip=".$db->escape_binary($this->packedip));
$session = $db->fetch_array($query);
if($session['sid'])


// Load the session if not using a bot sid
if(substr($sid, 3, 1) !== '=')


			{

			{

				$this->sid = $session['sid'];






				$query = $db->simple_select("sessions", "*", "sid='{$sid}'");
$session = $db->fetch_array($query);
if($session['sid'])
{
$this->sid = $session['sid'];
}

			}

			}

 
		}

if(isset($plugins))
{
$plugins->run_hooks('pre_session_load', $this);

		}

// If we have a valid session id and user id, load that users session.

		}

// If we have a valid session id and user id, load that users session.

Zeile 99Zeile 118
		if($this->sid && (!isset($mybb->cookies['sid']) || $mybb->cookies['sid'] != $this->sid) && $this->is_spider != true)
{
my_setcookie("sid", $this->sid, -1, true);

		if($this->sid && (!isset($mybb->cookies['sid']) || $mybb->cookies['sid'] != $this->sid) && $this->is_spider != true)
{
my_setcookie("sid", $this->sid, -1, true);

		}

		}

	}

	}





	/**
* Load a user via the user credentials.
*

	/**
* Load a user via the user credentials.
*

Zeile 112Zeile 131
	function load_user($uid, $loginkey='')
{
global $mybb, $db, $time, $lang, $mybbgroups, $cache;

	function load_user($uid, $loginkey='')
{
global $mybb, $db, $time, $lang, $mybbgroups, $cache;


// Read the banned cache
$bannedcache = $cache->read("banned");

// If the banned cache doesn't exist, update it and re-read it
if(!is_array($bannedcache))
{
$cache->update_banned();
$bannedcache = $cache->read("banned");
}

 

$uid = (int)$uid;
$query = $db->query("


$uid = (int)$uid;
$query = $db->query("

Zeile 132Zeile 141
			LIMIT 1
");
$mybb->user = $db->fetch_array($query);

			LIMIT 1
");
$mybb->user = $db->fetch_array($query);


if(!empty($bannedcache[$uid]))
{
$banned_user = $bannedcache[$uid];
$mybb->user['bandate'] = $banned_user['dateline'];
$mybb->user['banlifted'] = $banned_user['lifted'];
$mybb->user['banoldgroup'] = $banned_user['oldgroup'];
$mybb->user['banolddisplaygroup'] = $banned_user['olddisplaygroup'];
$mybb->user['banoldadditionalgroups'] = $banned_user['oldadditionalgroups'];
}

 

// Check the password if we're not using a session
if(empty($loginkey) || $loginkey !== $mybb->user['loginkey'] || !$mybb->user['uid'])


// Check the password if we're not using a session
if(empty($loginkey) || $loginkey !== $mybb->user['loginkey'] || !$mybb->user['uid'])

Zeile 228Zeile 227

// Find out the threads per page preference.
if($mybb->user['tpp'])


// Find out the threads per page preference.
if($mybb->user['tpp'])

		{

		{

			$mybb->settings['threadsperpage'] = $mybb->user['tpp'];
}


			$mybb->settings['threadsperpage'] = $mybb->user['tpp'];
}


Zeile 236Zeile 235
		if($mybb->user['ppp'])
{
$mybb->settings['postsperpage'] = $mybb->user['ppp'];

		if($mybb->user['ppp'])
{
$mybb->settings['postsperpage'] = $mybb->user['ppp'];

		}

		}


// Does this user prefer posts in classic mode?
if($mybb->user['classicpostbit'])


// Does this user prefer posts in classic mode?
if($mybb->user['classicpostbit'])

Zeile 246Zeile 245
		else
{
$mybb->settings['postlayout'] = 'horizontal';

		else
{
$mybb->settings['postlayout'] = 'horizontal';

 
		}

$usergroups = $cache->read('usergroups');

if(!empty($usergroups[$mybb->user['usergroup']]) && $usergroups[$mybb->user['usergroup']]['isbannedgroup'] == 1)
{
$ban = $db->fetch_array(
$db->simple_select('banned', '*', 'uid='.(int)$mybb->user['uid'], array('limit' => 1))
);

if($ban)
{
$mybb->user['banned'] = 1;
$mybb->user['bandate'] = $ban['dateline'];
$mybb->user['banlifted'] = $ban['lifted'];
$mybb->user['banoldgroup'] = $ban['oldgroup'];
$mybb->user['banolddisplaygroup'] = $ban['olddisplaygroup'];
$mybb->user['banoldadditionalgroups'] = $ban['oldadditionalgroups'];
$mybb->user['banreason'] = $ban['reason'];
}
else
{
$mybb->user['banned'] = 0;
}

		}

// Check if this user is currently banned and if we have to lift it.
if(!empty($mybb->user['bandate']) && (isset($mybb->user['banlifted']) && !empty($mybb->user['banlifted'])) && $mybb->user['banlifted'] < $time) // hmmm...bad user... how did you get banned =/

		}

// Check if this user is currently banned and if we have to lift it.
if(!empty($mybb->user['bandate']) && (isset($mybb->user['banlifted']) && !empty($mybb->user['banlifted'])) && $mybb->user['banlifted'] < $time) // hmmm...bad user... how did you get banned =/

		{

		{

			// must have been good.. bans up :D
$db->shutdown_query("UPDATE ".TABLE_PREFIX."users SET usergroup='".(int)$mybb->user['banoldgroup']."', additionalgroups='".$mybb->user['banoldadditionalgroups']."', displaygroup='".(int)$mybb->user['banolddisplaygroup']."' WHERE uid='".$mybb->user['uid']."'");
$db->shutdown_query("DELETE FROM ".TABLE_PREFIX."banned WHERE uid='".$mybb->user['uid']."'");

			// must have been good.. bans up :D
$db->shutdown_query("UPDATE ".TABLE_PREFIX."users SET usergroup='".(int)$mybb->user['banoldgroup']."', additionalgroups='".$mybb->user['banoldadditionalgroups']."', displaygroup='".(int)$mybb->user['banolddisplaygroup']."' WHERE uid='".$mybb->user['uid']."'");
$db->shutdown_query("DELETE FROM ".TABLE_PREFIX."banned WHERE uid='".$mybb->user['uid']."'");

Zeile 258Zeile 281
			$mybb->user['usergroup'] = $mybb->user['banoldgroup'];
$mybb->user['displaygroup'] = $mybb->user['banolddisplaygroup'];
$mybb->user['additionalgroups'] = $mybb->user['banoldadditionalgroups'];

			$mybb->user['usergroup'] = $mybb->user['banoldgroup'];
$mybb->user['displaygroup'] = $mybb->user['banolddisplaygroup'];
$mybb->user['additionalgroups'] = $mybb->user['banoldadditionalgroups'];

			$cache->update_banned();

 

$mybbgroups = $mybb->user['usergroup'];
if($mybb->user['additionalgroups'])


$mybbgroups = $mybb->user['usergroup'];
if($mybb->user['additionalgroups'])

Zeile 284Zeile 306
		if(!$mybb->user['displaygroup'])
{
$mybb->user['displaygroup'] = $mybb->user['usergroup'];

		if(!$mybb->user['displaygroup'])
{
$mybb->user['displaygroup'] = $mybb->user['usergroup'];

		}

$mydisplaygroup = usergroup_displaygroup($mybb->user['displaygroup']);
if(is_array($mydisplaygroup))
{

		}

$mydisplaygroup = usergroup_displaygroup($mybb->user['displaygroup']);
if(is_array($mydisplaygroup))
{

			$mybb->usergroup = array_merge($mybb->usergroup, $mydisplaygroup);
}

if(!$mybb->user['usertitle'])
{
$mybb->user['usertitle'] = $mybb->usergroup['usertitle'];

			$mybb->usergroup = array_merge($mybb->usergroup, $mydisplaygroup);
}

if(!$mybb->user['usertitle'])
{
$mybb->user['usertitle'] = $mybb->usergroup['usertitle'];

		}

		}


// Update or create the session.
if(!defined("NO_ONLINE") && !defined('IN_UPGRADE'))


// Update or create the session.
if(!defined("NO_ONLINE") && !defined('IN_UPGRADE'))

Zeile 338Zeile 360
				$mybb->cookies['mybb']['lastactive'] = $mybb->user['lastactive'];
}
else

				$mybb->cookies['mybb']['lastactive'] = $mybb->user['lastactive'];
}
else

			{

			{

				$mybb->user['lastactive'] = (int)$mybb->cookies['mybb']['lastactive'];
}
if($time - $mybb->cookies['mybb']['lastactive'] > 900)
{
my_setcookie("mybb[lastvisit]", $mybb->user['lastactive']);
$mybb->user['lastvisit'] = $mybb->user['lastactive'];

				$mybb->user['lastactive'] = (int)$mybb->cookies['mybb']['lastactive'];
}
if($time - $mybb->cookies['mybb']['lastactive'] > 900)
{
my_setcookie("mybb[lastvisit]", $mybb->user['lastactive']);
$mybb->user['lastvisit'] = $mybb->user['lastactive'];

			}

			}

			else
{
$mybb->user['lastvisit'] = (int)$mybb->cookies['mybb']['lastactive'];

			else
{
$mybb->user['lastvisit'] = (int)$mybb->cookies['mybb']['lastactive'];

Zeile 374Zeile 396
		if(!defined("NO_ONLINE") && !defined('IN_UPGRADE'))
{
if(!empty($this->sid))

		if(!defined("NO_ONLINE") && !defined('IN_UPGRADE'))
{
if(!empty($this->sid))

			{

			{

				$this->update_session($this->sid);
}
else

				$this->update_session($this->sid);
}
else

Zeile 403Zeile 425
		if($spider['usergroup'])
{
$mybb->user['usergroup'] = $spider['usergroup'];

		if($spider['usergroup'])
{
$mybb->user['usergroup'] = $spider['usergroup'];

		}

		}

		else
{
$mybb->user['usergroup'] = 1;

		else
{
$mybb->user['usergroup'] = 1;

Zeile 411Zeile 433
		$mybb->user['username'] = '';
$mybb->user['uid'] = 0;
$mybb->user['displaygroup'] = $mybb->user['usergroup'];

		$mybb->user['username'] = '';
$mybb->user['uid'] = 0;
$mybb->user['displaygroup'] = $mybb->user['usergroup'];





		// Set spider language
if($spider['language'] && $lang->language_exists($spider['language']))
{

		// Set spider language
if($spider['language'] && $lang->language_exists($spider['language']))
{

Zeile 439Zeile 461
				"lastvisit" => TIME_NOW
);
$db->update_query("spiders", $updated_spider, "sid='{$spider_id}'");

				"lastvisit" => TIME_NOW
);
$db->update_query("spiders", $updated_spider, "sid='{$spider_id}'");

		}


		}


		// Update the online data.
if(!defined("NO_ONLINE") && !defined('IN_UPGRADE'))
{
$this->sid = "bot=".$spider_id;
$this->create_session();
}

		// Update the online data.
if(!defined("NO_ONLINE") && !defined('IN_UPGRADE'))
{
$this->sid = "bot=".$spider_id;
$this->create_session();
}





	}

/**

	}

/**

Zeile 461Zeile 483
		global $db;

// Find out what the special locations are.

		global $db;

// Find out what the special locations are.

		$speciallocs = $this->get_special_locations();

		$speciallocs = $this->get_special_locations();

		if($uid)

		if($uid)

		{
$onlinedata['uid'] = $uid;
}
else
{
$onlinedata['uid'] = 0;
}

		{
$onlinedata['uid'] = $uid;
}
else
{
$onlinedata['uid'] = 0;
}

		$onlinedata['time'] = TIME_NOW;

		$onlinedata['time'] = TIME_NOW;

		
$onlinedata['location'] = $db->escape_string(substr(get_current_location(), 0, 150));


$onlinedata['location'] = $db->escape_string(substr(get_current_location(false, $this->ignore_parameters), 0, 150));

		$onlinedata['useragent'] = $db->escape_string(my_substr($this->useragent, 0, 200));

$onlinedata['location1'] = (int)$speciallocs['1'];

		$onlinedata['useragent'] = $db->escape_string(my_substr($this->useragent, 0, 200));

$onlinedata['location1'] = (int)$speciallocs['1'];

Zeile 513Zeile 535
		if($this->is_spider == true)
{
$onlinedata['sid'] = $this->sid;

		if($this->is_spider == true)
{
$onlinedata['sid'] = $this->sid;

		}

		}

		else
{
$onlinedata['sid'] = md5(random_str(50));
}
$onlinedata['time'] = TIME_NOW;
$onlinedata['ip'] = $db->escape_binary($this->packedip);

		else
{
$onlinedata['sid'] = md5(random_str(50));
}
$onlinedata['time'] = TIME_NOW;
$onlinedata['ip'] = $db->escape_binary($this->packedip);

		
$onlinedata['location'] = $db->escape_string(substr(get_current_location(), 0, 150));


$onlinedata['location'] = $db->escape_string(substr(get_current_location(false, $this->ignore_parameters), 0, 150));

		$onlinedata['useragent'] = $db->escape_string(my_substr($this->useragent, 0, 200));

$onlinedata['location1'] = (int)$speciallocs['1'];

		$onlinedata['useragent'] = $db->escape_string(my_substr($this->useragent, 0, 200));

$onlinedata['location1'] = (int)$speciallocs['1'];