Vergleich inc/class_session.php - 1.8.12 - 1.8.26

  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();
$this->packedip = my_inet_pton($this->ipaddress);

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





		// Find out the user agent.
$this->useragent = $_SERVER['HTTP_USER_AGENT'];

		// Find out the user agent.
$this->useragent = $_SERVER['HTTP_USER_AGENT'];





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

		// Attempt to find a session id in the cookies.
if(isset($mybb->cookies['sid']) && !defined('IN_UPGRADE'))
{
$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 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'])

		{

		{

			unset($mybb->user);
$this->uid = 0;
return false;

			unset($mybb->user);
$this->uid = 0;
return false;

Zeile 166Zeile 165
			if($mybb->user['unreadpms'] == -1)
{
$update += 2;

			if($mybb->user['unreadpms'] == -1)
{
$update += 2;

			}

require_once MYBB_ROOT."inc/functions_user.php";

			}

require_once MYBB_ROOT."inc/functions_user.php";

			$pmcount = update_pm_count('', $update);
if(is_array($pmcount))
{

			$pmcount = update_pm_count('', $update);
if(is_array($pmcount))
{

Zeile 181Zeile 180
		if($mybb->user['lastip'] != $this->packedip && array_key_exists('lastip', $mybb->user) && !defined('IN_UPGRADE'))
{
$lastip_add = ", lastip=".$db->escape_binary($this->packedip);

		if($mybb->user['lastip'] != $this->packedip && array_key_exists('lastip', $mybb->user) && !defined('IN_UPGRADE'))
{
$lastip_add = ", lastip=".$db->escape_binary($this->packedip);

		}
else
{

		}
else
{

			$lastip_add = '';
}

// If the last visit was over 900 seconds (session time out) ago then update lastvisit.
$time = TIME_NOW;
if($time - $mybb->user['lastactive'] > 900)

			$lastip_add = '';
}

// If the last visit was over 900 seconds (session time out) ago then update lastvisit.
$time = TIME_NOW;
if($time - $mybb->user['lastactive'] > 900)

		{

		{

			$db->shutdown_query("UPDATE ".TABLE_PREFIX."users SET lastvisit='{$mybb->user['lastactive']}', lastactive='$time'{$lastip_add} WHERE uid='{$mybb->user['uid']}'");
$mybb->user['lastvisit'] = $mybb->user['lastactive'];
require_once MYBB_ROOT."inc/functions_user.php";
update_pm_count('', 2);
}
else

			$db->shutdown_query("UPDATE ".TABLE_PREFIX."users SET lastvisit='{$mybb->user['lastactive']}', lastactive='$time'{$lastip_add} WHERE uid='{$mybb->user['uid']}'");
$mybb->user['lastvisit'] = $mybb->user['lastactive'];
require_once MYBB_ROOT."inc/functions_user.php";
update_pm_count('', 2);
}
else

		{

		{

			$timespent = TIME_NOW - $mybb->user['lastactive'];
$db->shutdown_query("UPDATE ".TABLE_PREFIX."users SET lastactive='$time', timeonline=timeonline+$timespent{$lastip_add} WHERE uid='{$mybb->user['uid']}'");
}

// Sort out the language and forum preferences.
if($mybb->user['language'] && $lang->language_exists($mybb->user['language']))

			$timespent = TIME_NOW - $mybb->user['lastactive'];
$db->shutdown_query("UPDATE ".TABLE_PREFIX."users SET lastactive='$time', timeonline=timeonline+$timespent{$lastip_add} WHERE uid='{$mybb->user['uid']}'");
}

// Sort out the language and forum preferences.
if($mybb->user['language'] && $lang->language_exists($mybb->user['language']))

		{

		{

			$mybb->settings['bblanguage'] = $mybb->user['language'];
}
if($mybb->user['dateformat'] != 0 && $mybb->user['dateformat'] != '')
{
global $date_formats;
if($date_formats[$mybb->user['dateformat']])

			$mybb->settings['bblanguage'] = $mybb->user['language'];
}
if($mybb->user['dateformat'] != 0 && $mybb->user['dateformat'] != '')
{
global $date_formats;
if($date_formats[$mybb->user['dateformat']])

			{

			{

				$mybb->settings['dateformat'] = $date_formats[$mybb->user['dateformat']];
}
}

				$mybb->settings['dateformat'] = $date_formats[$mybb->user['dateformat']];
}
}

Zeile 223Zeile 222
			if($time_formats[$mybb->user['timeformat']])
{
$mybb->settings['timeformat'] = $time_formats[$mybb->user['timeformat']];

			if($time_formats[$mybb->user['timeformat']])
{
$mybb->settings['timeformat'] = $time_formats[$mybb->user['timeformat']];

			}
}


			}
}


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

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

Zeile 240Zeile 239

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


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

		{

		{

			$mybb->settings['postlayout'] = 'classic';

			$mybb->settings['postlayout'] = 'classic';

		}

		}

		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 =/
{
// must have been good.. bans up :D

		// 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("UPDATE ".TABLE_PREFIX."users SET usergroup='".(int)$mybb->user['banoldgroup']."', additionalgroups='".$db->escape_string($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']."'");
// we better do this..otherwise they have dodgy permissions
$mybb->user['usergroup'] = $mybb->user['banoldgroup'];
$mybb->user['displaygroup'] = $mybb->user['banolddisplaygroup'];
$mybb->user['additionalgroups'] = $mybb->user['banoldadditionalgroups'];

			$db->shutdown_query("DELETE FROM ".TABLE_PREFIX."banned WHERE uid='".$mybb->user['uid']."'");
// we better do this..otherwise they have dodgy permissions
$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['additionalgroups'];


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


			}
}
else if(!empty($mybb->user['bandate']) && (empty($mybb->user['banlifted']) || !empty($mybb->user['banlifted']) && $mybb->user['banlifted'] > $time))

			}
}
else if(!empty($mybb->user['bandate']) && (empty($mybb->user['banlifted']) || !empty($mybb->user['banlifted']) && $mybb->user['banlifted'] > $time))

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))

Zeile 299Zeile 321

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


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

		{

		{

			if(!empty($this->sid))
{
$this->update_session($this->sid, $mybb->user['uid']);

			if(!empty($this->sid))
{
$this->update_session($this->sid, $mybb->user['uid']);

Zeile 323Zeile 345
		// Set up some defaults
$time = TIME_NOW;
$mybb->user['usergroup'] = 1;

		// Set up some defaults
$time = TIME_NOW;
$mybb->user['usergroup'] = 1;

 
		$mybb->user['additionalgroups'] = '';

		$mybb->user['username'] = '';
$mybb->user['uid'] = 0;
$mybbgroups = 1;

		$mybb->user['username'] = '';
$mybb->user['uid'] = 0;
$mybbgroups = 1;

Zeile 341Zeile 364
				$mybb->user['lastactive'] = (int)$mybb->cookies['mybb']['lastactive'];
}
if($time - $mybb->cookies['mybb']['lastactive'] > 900)

				$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'];

				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'];
}

		}


		}


		// No last visit cookie, create one.
else

		// No last visit cookie, create one.
else

		{

		{

			my_setcookie("mybb[lastvisit]", $time);
$mybb->user['lastvisit'] = $time;

			my_setcookie("mybb[lastvisit]", $time);
$mybb->user['lastvisit'] = $time;

		}

		}


// Update last active cookie.
my_setcookie("mybb[lastactive]", $time);


// Update last active cookie.
my_setcookie("mybb[lastactive]", $time);

Zeile 364Zeile 387
		// Gather a full permission set for this guest
$mybb->usergroup = usergroup_permissions($mybbgroups);
$mydisplaygroup = usergroup_displaygroup($mybb->user['displaygroup']);

		// Gather a full permission set for this guest
$mybb->usergroup = usergroup_permissions($mybbgroups);
$mydisplaygroup = usergroup_displaygroup($mybb->user['displaygroup']);


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



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


// Update the online data.
if(!defined("NO_ONLINE") && !defined('IN_UPGRADE'))


// Update the online data.
if(!defined("NO_ONLINE") && !defined('IN_UPGRADE'))

Zeile 424Zeile 449
		// Gather a full permission set for this spider.
$mybb->usergroup = usergroup_permissions($mybb->user['usergroup']);
$mydisplaygroup = usergroup_displaygroup($mybb->user['displaygroup']);

		// Gather a full permission set for this spider.
$mybb->usergroup = usergroup_permissions($mybb->user['usergroup']);
$mydisplaygroup = usergroup_displaygroup($mybb->user['displaygroup']);

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




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


// Update spider last minute (only do so on two minute intervals - decrease load for quick spiders)
if($spider['lastvisit'] < TIME_NOW-120)


// Update spider last minute (only do so on two minute intervals - decrease load for quick spiders)
if($spider['lastvisit'] < TIME_NOW-120)

Zeile 433Zeile 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'))


// Update the online data.
if(!defined("NO_ONLINE") && !defined('IN_UPGRADE'))

Zeile 441Zeile 469
			$this->sid = "bot=".$spider_id;
$this->create_session();
}

			$this->sid = "bot=".$spider_id;
$this->create_session();
}





	}

/**

	}

/**

Zeile 457Zeile 485
		// Find out what the special locations are.
$speciallocs = $this->get_special_locations();
if($uid)

		// Find out what the special locations are.
$speciallocs = $this->get_special_locations();
if($uid)

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

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

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

$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 486Zeile 514
	{
global $db;
$speciallocs = $this->get_special_locations();

	{
global $db;
$speciallocs = $this->get_special_locations();





		// If there is a proper uid, delete by uid.
if($uid > 0)
{

		// If there is a proper uid, delete by uid.
if($uid > 0)
{

Zeile 498Zeile 526
		{
$db->delete_query("sessions", "sid='{$this->sid}'");
}

		{
$db->delete_query("sessions", "sid='{$this->sid}'");
}

		// Else delete by ip.

 
		else
{

		else
{

			$db->delete_query("sessions", "ip=".$db->escape_binary($this->packedip));

 
			$onlinedata['uid'] = 0;
}


			$onlinedata['uid'] = 0;
}


Zeile 509Zeile 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'];

Zeile 537Zeile 563
	{
global $mybb;
$array = array('1' => '', '2' => '');

	{
global $mybb;
$array = array('1' => '', '2' => '');

		if(preg_match("#forumdisplay.php#", $_SERVER['PHP_SELF']) && $mybb->get_input('fid', MyBB::INPUT_INT) > 0)

		if(preg_match("#forumdisplay.php#", $_SERVER['PHP_SELF']) && $mybb->get_input('fid', MyBB::INPUT_INT) > 0 && $mybb->get_input('fid', MyBB::INPUT_INT) < 4294967296)

		{
$array[1] = $mybb->get_input('fid', MyBB::INPUT_INT);
$array[2] = '';

		{
$array[1] = $mybb->get_input('fid', MyBB::INPUT_INT);
$array[2] = '';

Zeile 546Zeile 572
		{
global $db;


		{
global $db;


			if($mybb->get_input('tid', MyBB::INPUT_INT) > 0)

			if($mybb->get_input('tid', MyBB::INPUT_INT) > 0 && $mybb->get_input('tid', MyBB::INPUT_INT) < 4294967296)

			{
$array[2] = $mybb->get_input('tid', MyBB::INPUT_INT);
}

			{
$array[2] = $mybb->get_input('tid', MyBB::INPUT_INT);
}