Vergleich inc/class_session.php - 1.6.9 - 1.6.17

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 16Zeile 16
	public $ipaddress = '';
public $useragent = '';
public $is_spider = false;

	public $ipaddress = '';
public $useragent = '';
public $is_spider = false;

	public $logins = 1;
public $failedlogin = 0;

 

/**
* Initialize a session


/**
* Initialize a session

Zeile 31Zeile 29

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


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

		if(my_strlen($this->useragent) > 100)
{
$this->useragent = my_substr($this->useragent, 0, 100);
}








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

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

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

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

			// Load the session

			// Load the session

			$query = $db->simple_select("sessions", "*", "sid='{$this->sid}' AND ip='".$db->escape_string($this->ipaddress)."'", array('limit' => 1));

			$query = $db->simple_select("sessions", "*", "sid='{$sid}' AND ip='".$db->escape_string($this->ipaddress)."'");

			$session = $db->fetch_array($query);
if($session['sid'])
{
$this->sid = $session['sid'];

			$session = $db->fetch_array($query);
if($session['sid'])
{
$this->sid = $session['sid'];

				$this->uid = $session['uid'];
}
else
{
$this->sid = 0;
$this->uid = 0;
$this->logins = 1;
$this->failedlogin = 0;
}
}

// Still no session, fall back
if(!$this->sid)
{
$this->sid = 0;
$this->uid = 0;
$this->logins = 1;
$this->failedlogin = 0;
}


			}
}



















		// 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.

		if($mybb->cookies['mybbuser'])

		if(!empty($mybb->cookies['mybbuser']))

		{
$logon = explode("_", $mybb->cookies['mybbuser'], 2);
$this->load_user($logon[0], $logon[1]);

		{
$logon = explode("_", $mybb->cookies['mybbuser'], 2);
$this->load_user($logon[0], $logon[1]);

		}


		}


		// If no user still, then we have a guest.
if(!isset($mybb->user['uid']))
{
// Detect if this guest is a search engine spider. (bots don't get a cookied session ID so we first see if that's set)
if(!$this->sid)

		// If no user still, then we have a guest.
if(!isset($mybb->user['uid']))
{
// Detect if this guest is a search engine spider. (bots don't get a cookied session ID so we first see if that's set)
if(!$this->sid)

			{

			{

				$spiders = $cache->read("spiders");
if(is_array($spiders))
{

				$spiders = $cache->read("spiders");
if(is_array($spiders))
{

Zeile 90Zeile 67
						}
}
}

						}
}
}

			}

			}


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


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

Zeile 101Zeile 78


// As a token of our appreciation for getting this far (and they aren't a spider), give the user a cookie



// As a token of our appreciation for getting this far (and they aren't a spider), give the user a cookie

		if($this->sid && ($mybb->cookies['sid'] != $this->sid) && $this->is_spider != true)

		if($this->sid && (!isset($mybb->cookies['sid']) || $mybb->cookies['sid'] != $this->sid) && $this->is_spider != true)

		{
my_setcookie("sid", $this->sid, -1, true);

		{
my_setcookie("sid", $this->sid, -1, true);

		}
}


		}
}


	/**
* Load a user via the user credentials.
*
* @param int The user id.

	/**
* Load a user via the user credentials.
*
* @param int The user id.

	 * @param string The user's password.

	 * @param string The user's loginkey.

	 */

	 */

	function load_user($uid, $password='')

	function load_user($uid, $loginkey='')

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

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

		



		// Read the banned cache

		// Read the banned cache

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


		$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");
}

		// 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 = intval($uid);
$query = $db->query("
SELECT u.*, f.*

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

			FROM ".TABLE_PREFIX."users u 
LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)

			FROM ".TABLE_PREFIX."users u
LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)

			WHERE u.uid='$uid'
LIMIT 1
");
$mybb->user = $db->fetch_array($query);

			WHERE u.uid='$uid'
LIMIT 1
");
$mybb->user = $db->fetch_array($query);

		
$this->logins = $mybb->user['loginattempts'];
$this->failedlogin = $mybb->user['failedlogin'];

if($bannedcache[$uid])


if(!empty($bannedcache[$uid]))




		{
$banned_user = $bannedcache[$uid];
$mybb->user['bandate'] = $banned_user['dateline'];

		{
$banned_user = $bannedcache[$uid];
$mybb->user['bandate'] = $banned_user['dateline'];

Zeile 151Zeile 125
		}

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

		}

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

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

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

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

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

Zeile 187Zeile 161

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


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

			$lastip_add .= ", lastip='".$db->escape_string($this->ipaddress)."', longlastip='".intval(my_ip2long($this->ipaddress))."'";





			$lastip_add = ", lastip='".$db->escape_string($this->ipaddress)."', longlastip='".intval(my_ip2long($this->ipaddress))."'";
}
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)
{

		}

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

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

			$mybb->user['lastvisit'] = $mybb->user['lastactive'];
require_once MYBB_ROOT."inc/functions_user.php";
update_pm_count('', 2);

Zeile 202Zeile 180
		else
{
$timespent = TIME_NOW - $mybb->user['lastactive'];

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

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


// 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($mybb->user['dateformat'] != 0 && $mybb->user['dateformat'] != '')
{
global $date_formats;

Zeile 221Zeile 199

// Choose time format.
if($mybb->user['timeformat'] != 0 && $mybb->user['timeformat'] != '')


// Choose time format.
if($mybb->user['timeformat'] != 0 && $mybb->user['timeformat'] != '')

		{

		{

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

			global $time_formats;
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'])
{
$mybb->settings['threadsperpage'] = $mybb->user['tpp'];


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

		}


		}


		// Find out the posts per page preference.
if($mybb->user['ppp'])
{
$mybb->settings['postsperpage'] = $mybb->user['ppp'];
}

		// Find out the posts per page preference.
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 255Zeile 233
		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

		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='".intval($mybb->user['banoldgroup'])."', additionalgroups='".$mybb->user['oldadditionalgroups']."', displaygroup='".intval($mybb->user['olddisplaygroup'])."' WHERE uid='".$mybb->user['uid']."' LIMIT 1");

			$db->shutdown_query("UPDATE ".TABLE_PREFIX."users SET usergroup='".intval($mybb->user['banoldgroup'])."', additionalgroups='".$mybb->user['banoldadditionalgroups']."', displaygroup='".intval($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'];

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

Zeile 294Zeile 272
		{
$mybb->usergroup = array_merge($mybb->usergroup, $mydisplaygroup);
}

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

		



		if(!$mybb->user['usertitle'])

		if(!$mybb->user['usertitle'])

		{

		{

			$mybb->user['usertitle'] = $mybb->usergroup['usertitle'];
}

// Update or create the session.

			$mybb->user['usertitle'] = $mybb->usergroup['usertitle'];
}

// Update or create the session.

		if(!defined("NO_ONLINE"))
{

		if(!defined("NO_ONLINE"))
{

			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 367Zeile 345
		// 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);

// Update the online data.

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

// Update the online data.

Zeile 394Zeile 372
		global $mybb, $time, $db, $lang;

// Fetch the spider preferences from the database

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

// Fetch the spider preferences from the database

		$query = $db->simple_select("spiders", "*", "sid='{$spider_id}'", array('limit' => 1));

		$query = $db->simple_select("spiders", "*", "sid='{$spider_id}'");

		$spider = $db->fetch_array($query);

// Set up some defaults

		$spider = $db->fetch_array($query);

// Set up some defaults

Zeile 435Zeile 413
			$updated_spider = array(
"lastvisit" => TIME_NOW
);

			$updated_spider = array(
"lastvisit" => TIME_NOW
);

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

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

		}

// Update the online data.

		}

// Update the online data.

Zeile 469Zeile 447
		}
$onlinedata['time'] = TIME_NOW;
$onlinedata['location'] = $db->escape_string(get_current_location());

		}
$onlinedata['time'] = TIME_NOW;
$onlinedata['location'] = $db->escape_string(get_current_location());

		$onlinedata['useragent'] = $db->escape_string($this->useragent);






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

		$onlinedata['location1'] = intval($speciallocs['1']);
$onlinedata['location2'] = intval($speciallocs['2']);
$onlinedata['nopermission'] = 0;
$sid = $db->escape_string($sid);


		$onlinedata['location1'] = intval($speciallocs['1']);
$onlinedata['location2'] = intval($speciallocs['2']);
$onlinedata['nopermission'] = 0;
$sid = $db->escape_string($sid);


		$db->update_query("sessions", $onlinedata, "sid='{$sid}'", 1);

		$db->update_query("sessions", $onlinedata, "sid='{$sid}'");

	}

/**

	}

/**

Zeile 518Zeile 501
		$onlinedata['time'] = TIME_NOW;
$onlinedata['ip'] = $db->escape_string($this->ipaddress);
$onlinedata['location'] = $db->escape_string(get_current_location());

		$onlinedata['time'] = TIME_NOW;
$onlinedata['ip'] = $db->escape_string($this->ipaddress);
$onlinedata['location'] = $db->escape_string(get_current_location());

		$onlinedata['useragent'] = $db->escape_string($this->useragent);






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

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

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

Zeile 541Zeile 529
			$array[1] = intval($mybb->input['fid']);
$array[2] = '';
}

			$array[1] = intval($mybb->input['fid']);
$array[2] = '';
}

		elseif(preg_match("#showthread.php#", $_SERVER['PHP_SELF']) && intval($mybb->input['tid']) > 0)

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

		{
global $db;

		{
global $db;

			$array[2] = intval($mybb->input['tid']);
$thread = get_thread(intval($array[2]));

















if(isset($mybb->input['tid']) && intval($mybb->input['tid']) > 0)
{
$array[2] = intval($mybb->input['tid']);
}
// If there is no tid but a pid, trick the system into thinking there was a tid anyway.
elseif(isset($mybb->input['pid']) && !empty($mybb->input['pid']))
{
$options = array(
"limit" => 1
);
$query = $db->simple_select("posts", "tid", "pid=".$mybb->input['pid'], $options);
$post = $db->fetch_array($query);
$array[2] = $post['tid'];
}

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

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

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