Vergleich inc/class_session.php - 1.8.3 - 1.8.12

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 10Zeile 10

class session
{


class session
{

 
	/**
* @var int
*/

	public $sid = 0;

	public $sid = 0;

 
	/**
* @var int
*/

	public $uid = 0;

	public $uid = 0;

 
	/**
* @var string
*/

	public $ipaddress = '';

	public $ipaddress = '';

 
	/**
* @var string
*/

	public $packedip = '';

	public $packedip = '';

 
	/**
* @var string
*/

	public $useragent = '';

	public $useragent = '';

 
	/**
* @var bool
*/

	public $is_spider = false;

/**

	public $is_spider = false;

/**

Zeile 32Zeile 50
		$this->useragent = $_SERVER['HTTP_USER_AGENT'];

// Attempt to find a session id in the cookies.

		$this->useragent = $_SERVER['HTTP_USER_AGENT'];

// Attempt to find a session id in the cookies.

		if(isset($mybb->cookies['sid']))
{

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

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

Zeile 68Zeile 86
						}
}
}

						}
}
}

			}


			}


			// Still nothing? JUST A GUEST!
if(!$this->is_spider)
{

			// Still nothing? JUST A GUEST!
if(!$this->is_spider)
{

Zeile 87Zeile 105
	/**
* Load a user via the user credentials.
*

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

	 * @param int The user id.
* @param string The user's loginkey.


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

	 */
function load_user($uid, $loginkey='')
{

	 */
function load_user($uid, $loginkey='')
{

		global $mybb, $db, $time, $lang, $mybbgroups, $session, $cache;

		global $mybb, $db, $time, $lang, $mybbgroups, $cache;


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


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

Zeile 102Zeile 121
		{
$cache->update_banned();
$bannedcache = $cache->read("banned");

		{
$cache->update_banned();
$bannedcache = $cache->read("banned");

		}

		}


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


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

Zeile 125Zeile 144
		}

// 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(empty($loginkey) || $loginkey !== $mybb->user['loginkey'] || !$mybb->user['uid'])

		{
unset($mybb->user);
$this->uid = 0;
return false;
}
$this->uid = $mybb->user['uid'];

		{
unset($mybb->user);
$this->uid = 0;
return false;
}
$this->uid = $mybb->user['uid'];





		// Set the logout key for this user
$mybb->user['logoutkey'] = md5($mybb->user['loginkey']);


		// Set the logout key for this user
$mybb->user['logoutkey'] = md5($mybb->user['loginkey']);


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

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

			}

			}


require_once MYBB_ROOT."inc/functions_user.php";
$pmcount = update_pm_count('', $update);


require_once MYBB_ROOT."inc/functions_user.php";
$pmcount = update_pm_count('', $update);

Zeile 155Zeile 174
			{
$mybb->user = array_merge($mybb->user, $pmcount);
}

			{
$mybb->user = array_merge($mybb->user, $pmcount);
}

		}

		}

		$mybb->user['pms_total'] = $mybb->user['totalpms'];
$mybb->user['pms_unread'] = $mybb->user['unreadpms'];


		$mybb->user['pms_total'] = $mybb->user['totalpms'];
$mybb->user['pms_unread'] = $mybb->user['unreadpms'];


		if($mybb->user['lastip'] != $this->packedip && array_key_exists('lastip', $mybb->user))

		if($mybb->user['lastip'] != $this->packedip && array_key_exists('lastip', $mybb->user) && !defined('IN_UPGRADE'))

		{
$lastip_add = ", lastip=".$db->escape_binary($this->packedip);

		{
$lastip_add = ", lastip=".$db->escape_binary($this->packedip);

		}
else

		}
else

		{
$lastip_add = '';
}

		{
$lastip_add = '';
}

Zeile 178Zeile 197
			update_pm_count('', 2);
}
else

			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 279Zeile 298
		}

// Update or create the session.

		}

// Update or create the session.

		if(!defined("NO_ONLINE"))

		if(!defined("NO_ONLINE") && !defined('IN_UPGRADE'))

		{
if(!empty($this->sid))
{

		{
if(!empty($this->sid))
{

Zeile 311Zeile 330

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


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

		{

		{

			if(!isset($mybb->cookies['mybb']['lastactive']))
{
$mybb->user['lastactive'] = $time;

			if(!isset($mybb->cookies['mybb']['lastactive']))
{
$mybb->user['lastactive'] = $time;

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

// Update the online data.

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

// Update the online data.

		if(!defined("NO_ONLINE"))

		if(!defined("NO_ONLINE") && !defined('IN_UPGRADE'))

		{
if(!empty($this->sid))
{

		{
if(!empty($this->sid))
{

Zeile 365Zeile 384
	/**
* Load a search engine spider.
*

	/**
* Load a search engine spider.
*

	 * @param int The ID of the search engine spider

	 * @param int $spider_id The ID of the search engine spider

	 */
function load_spider($spider_id)
{

	 */
function load_spider($spider_id)
{

Zeile 417Zeile 436
		}

// Update the online data.

		}

// Update the online data.

		if(!defined("NO_ONLINE"))

		if(!defined("NO_ONLINE") && !defined('IN_UPGRADE'))

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

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

Zeile 428Zeile 447
	/**
* Update a user session.
*

	/**
* Update a user session.
*

	 * @param int The session id.
* @param int The user id.

	 * @param int $sid The session id.
* @param int $uid The user id.

	 */

	 */

	function update_session($sid, $uid='')

	function update_session($sid, $uid=0)

	{
global $db;


	{
global $db;


Zeile 446Zeile 465
			$onlinedata['uid'] = 0;
}
$onlinedata['time'] = TIME_NOW;

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

		$onlinedata['location'] = $db->escape_string(get_current_location());
$useragent = $this->useragent;
if(my_strlen($useragent) > 100)
{
$useragent = my_substr($useragent, 0, 100);
}
$onlinedata['useragent'] = $db->escape_string($useragent);

		
$onlinedata['location'] = $db->escape_string(substr(get_current_location(), 0, 150));
$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 464Zeile 480
	/**
* Create a new session.
*

	/**
* Create a new session.
*

	 * @param int The user id to bind the session to.

	 * @param int $uid The user id to bind the session to.

	 */
function create_session($uid=0)
{
global $db;
$speciallocs = $this->get_special_locations();

	 */
function create_session($uid=0)
{
global $db;
$speciallocs = $this->get_special_locations();





		// If there is a proper uid, delete by uid.
if($uid > 0)
{
$db->delete_query("sessions", "uid='{$uid}'");
$onlinedata['uid'] = $uid;

		// If there is a proper uid, delete by uid.
if($uid > 0)
{
$db->delete_query("sessions", "uid='{$uid}'");
$onlinedata['uid'] = $uid;

		}

		}

		// Is a spider - delete all other spider references
else if($this->is_spider == true)
{

		// Is a spider - delete all other spider references
else if($this->is_spider == true)
{

Zeile 487Zeile 503
		{
$db->delete_query("sessions", "ip=".$db->escape_binary($this->packedip));
$onlinedata['uid'] = 0;

		{
$db->delete_query("sessions", "ip=".$db->escape_binary($this->packedip));
$onlinedata['uid'] = 0;

		}

		}


// If the user is a search enginge spider, ...
if($this->is_spider == true)
{
$onlinedata['sid'] = $this->sid;


// If the user is a search enginge spider, ...
if($this->is_spider == true)
{
$onlinedata['sid'] = $this->sid;

		}

		}

		else

		else

		{
$onlinedata['sid'] = md5(uniqid(microtime(true), true));
}

		{
$onlinedata['sid'] = md5(random_str(50));
}

		$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(get_current_location());
$useragent = $this->useragent;
if(my_strlen($useragent) > 100)
{
$useragent = my_substr($useragent, 0, 100);
}
$onlinedata['useragent'] = $db->escape_string($useragent);

		
$onlinedata['location'] = $db->escape_string(substr(get_current_location(), 0, 150));
$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 524Zeile 537
	{
global $mybb;
$array = array('1' => '', '2' => '');

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

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

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

		{

		{

			$array[1] = $mybb->get_input('fid', 1);

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

			$array[2] = '';
}
elseif(preg_match("#showthread.php#", $_SERVER['PHP_SELF']))
{
global $db;


			$array[2] = '';
}
elseif(preg_match("#showthread.php#", $_SERVER['PHP_SELF']))
{
global $db;


			if($mybb->get_input('tid', 1) > 0)

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

			{

			{

				$array[2] = $mybb->get_input('tid', 1);

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

			}

// If there is no tid but a pid, trick the system into thinking there was a tid anyway.

			}

// If there is no tid but a pid, trick the system into thinking there was a tid anyway.

Zeile 544Zeile 557
				$options = array(
"limit" => 1
);

				$options = array(
"limit" => 1
);

				$query = $db->simple_select("posts", "tid", "pid=".$mybb->get_input('pid', 1), $options);

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

				$post = $db->fetch_array($query);
$array[2] = $post['tid'];
}

				$post = $db->fetch_array($query);
$array[2] = $post['tid'];
}