Vergleich inc/class_session.php - 1.8.22 - 1.8.37

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

// Find out the user agent.


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




		if(isset($_SERVER['HTTP_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'])
{
$this->sid = $session['sid'];






// Load the session if not using a bot sid
if(substr($sid, 3, 1) !== '=')
{
$query = $db->simple_select("sessions", "*", "sid='{$sid}'");
$session = $db->fetch_array($query);
if($session)
{
$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 104Zeile 126

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


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

	 *

	 *

	 * @param int $uid The user id.
* @param string $loginkey The user's loginkey.
* @return bool

	 * @param int $uid The user id.
* @param string $loginkey The user's loginkey.
* @return bool

Zeile 112Zeile 134
	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("
SELECT u.*, f.*

		$uid = (int)$uid;
$query = $db->query("
SELECT u.*, f.*

Zeile 132Zeile 144
			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


// Check the password if we're not using a session

		if(empty($loginkey) || $loginkey !== $mybb->user['loginkey'] || !$mybb->user['uid'])

		if(!$mybb->user || empty($loginkey) || $loginkey !== $mybb->user['loginkey'])

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

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

Zeile 210Zeile 212
		if($mybb->user['dateformat'] != 0 && $mybb->user['dateformat'] != '')
{
global $date_formats;

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

			if($date_formats[$mybb->user['dateformat']])

			if(!empty($date_formats[$mybb->user['dateformat']]))

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

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

Zeile 220Zeile 222
		if($mybb->user['timeformat'] != 0 && $mybb->user['timeformat'] != '')
{
global $time_formats;

		if($mybb->user['timeformat'] != 0 && $mybb->user['timeformat'] != '')
{
global $time_formats;

			if($time_formats[$mybb->user['timeformat']])

			if(!empty($time_formats[$mybb->user['timeformat']]))

			{
$mybb->settings['timeformat'] = $time_formats[$mybb->user['timeformat']];
}

			{
$mybb->settings['timeformat'] = $time_formats[$mybb->user['timeformat']];
}

Zeile 242Zeile 244
		if($mybb->user['classicpostbit'])
{
$mybb->settings['postlayout'] = 'classic';

		if($mybb->user['classicpostbit'])
{
$mybb->settings['postlayout'] = 'classic';

		}
else
{

		}
else
{

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

			$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['usergroup'];
if($mybb->user['additionalgroups'])


			{
$mybbgroups .= ','.$mybb->user['additionalgroups'];
}

			{
$mybbgroups .= ','.$mybb->user['additionalgroups'];
}

Zeile 269Zeile 294
		else if(!empty($mybb->user['bandate']) && (empty($mybb->user['banlifted'])  || !empty($mybb->user['banlifted']) && $mybb->user['banlifted'] > $time))
{
$mybbgroups = $mybb->user['usergroup'];

		else if(!empty($mybb->user['bandate']) && (empty($mybb->user['banlifted'])  || !empty($mybb->user['banlifted']) && $mybb->user['banlifted'] > $time))
{
$mybbgroups = $mybb->user['usergroup'];

        }

        }

        else
{
// Gather a full permission set for this user and the groups they are in.

        else
{
// Gather a full permission set for this user and the groups they are in.

Zeile 284Zeile 309
		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 303Zeile 328
			if(!empty($this->sid))
{
$this->update_session($this->sid, $mybb->user['uid']);

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

			}
else
{
$this->create_session($mybb->user['uid']);
}

			}
else
{
$this->create_session($mybb->user['uid']);
}

		}
return true;
}

		}
return true;
}

Zeile 328Zeile 353
		$mybb->user['uid'] = 0;
$mybbgroups = 1;
$mybb->user['displaygroup'] = 1;

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

 
		$mybb->user['invisible'] = 0;
$mybb->user['moderateposts'] = 0;
$mybb->user['showquickreply'] = 1;
$mybb->user['signature'] = '';
$mybb->user['suspendposting'] = 0;


// Has this user visited before? Lastvisit need updating?
if(isset($mybb->cookies['mybb']['lastvisit']))
{
if(!isset($mybb->cookies['mybb']['lastactive']))


// Has this user visited before? Lastvisit need updating?
if(isset($mybb->cookies['mybb']['lastvisit']))
{
if(!isset($mybb->cookies['mybb']['lastactive']))

			{

			{

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

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

Zeile 364Zeile 394

// Gather a full permission set for this guest
$mybb->usergroup = usergroup_permissions($mybbgroups);


// Gather a full permission set for this guest
$mybb->usergroup = usergroup_permissions($mybbgroups);

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


		$mydisplaygroup = usergroup_displaygroup($mybb->user['displaygroup']);
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 392Zeile 422
	function load_spider($spider_id)
{
global $mybb, $time, $db, $lang;

	function load_spider($spider_id)
{
global $mybb, $time, $db, $lang;





		// Fetch the spider preferences from the database
$query = $db->simple_select("spiders", "*", "sid='{$spider_id}'");
$spider = $db->fetch_array($query);

		// Fetch the spider preferences from the database
$query = $db->simple_select("spiders", "*", "sid='{$spider_id}'");
$spider = $db->fetch_array($query);

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

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


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


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

Zeile 430Zeile 462
		if(is_array($mydisplaygroup))
{
$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 446Zeile 478
		{
$this->sid = "bot=".$spider_id;
$this->create_session();

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

		}

		}


}



}


Zeile 461Zeile 493
		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)
{
$onlinedata['uid'] = $uid;

		if($uid)
{
$onlinedata['uid'] = $uid;

Zeile 471Zeile 503
			$onlinedata['uid'] = 0;
}
$onlinedata['time'] = TIME_NOW;

			$onlinedata['uid'] = 0;
}
$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['useragent'] = $db->escape_string(my_substr($this->useragent, 0, 200));

		



		$onlinedata['location1'] = (int)$speciallocs['1'];
$onlinedata['location2'] = (int)$speciallocs['2'];
$onlinedata['nopermission'] = 0;

		$onlinedata['location1'] = (int)$speciallocs['1'];
$onlinedata['location2'] = (int)$speciallocs['2'];
$onlinedata['nopermission'] = 0;

Zeile 495Zeile 527

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


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

		{

		{

			$db->delete_query("sessions", "uid='{$uid}'");
$onlinedata['uid'] = $uid;

			$db->delete_query("sessions", "uid='{$uid}'");
$onlinedata['uid'] = $uid;

		}
// Is a spider - delete all other spider references
else if($this->is_spider == true)
{
$db->delete_query("sessions", "sid='{$this->sid}'");

 
		}
else
{

		}
else
{

 
			// Is a spider - delete all other spider references
if($this->is_spider == true)
{
$db->delete_query("sessions", "sid='{$this->sid}'");
}


			$onlinedata['uid'] = 0;
}


			$onlinedata['uid'] = 0;
}


Zeile 520Zeile 553
		}
$onlinedata['time'] = TIME_NOW;
$onlinedata['ip'] = $db->escape_binary($this->packedip);

		}
$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['useragent'] = $db->escape_string(my_substr($this->useragent, 0, 200));

		



		$onlinedata['location1'] = (int)$speciallocs['1'];
$onlinedata['location2'] = (int)$speciallocs['2'];
$onlinedata['nopermission'] = 0;

		$onlinedata['location1'] = (int)$speciallocs['1'];
$onlinedata['location2'] = (int)$speciallocs['2'];
$onlinedata['nopermission'] = 0;

Zeile 539Zeile 572
	 */
function get_special_locations()
{

	 */
function get_special_locations()
{

		global $mybb;

		global $mybb, $db;

		$array = array('1' => '', '2' => '');
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 = array('1' => '', '2' => '');
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] = '';

 
		}
elseif(preg_match("#showthread.php#", $_SERVER['PHP_SELF']))
{

		}
elseif(preg_match("#showthread.php#", $_SERVER['PHP_SELF']))
{

			global $db;


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

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

Zeile 563Zeile 593
				);
$query = $db->simple_select("posts", "tid", "pid=".$mybb->get_input('pid', MyBB::INPUT_INT), $options);
$post = $db->fetch_array($query);

				);
$query = $db->simple_select("posts", "tid", "pid=".$mybb->get_input('pid', MyBB::INPUT_INT), $options);
$post = $db->fetch_array($query);

				$array[2] = $post['tid'];
}




				if($post)
{
$array[2] = $post['tid'];
}
}


$thread = get_thread($array[2]);


$thread = get_thread($array[2]);

			$array[1] = $thread['fid'];




			if($thread)
{
$array[1] = $thread['fid'];
}

		}
return $array;
}

		}
return $array;
}