diff options
| author | Joas Schilling <nickvergessen@gmx.de> | 2014-10-28 12:55:53 +0100 | 
|---|---|---|
| committer | Joas Schilling <nickvergessen@gmx.de> | 2014-10-28 12:56:15 +0100 | 
| commit | d2cd24e8750729110e06e42b507fd89cadb9e51e (patch) | |
| tree | f7f57a0047a44e5d859f85df7a9ad6618c1aa371 | |
| parent | d51c1707e3220173996af6fa0e870fc44ea3e94d (diff) | |
| parent | fcc320e3852215a11b863d0108e16e2be998d5cc (diff) | |
| download | forums-d2cd24e8750729110e06e42b507fd89cadb9e51e.tar forums-d2cd24e8750729110e06e42b507fd89cadb9e51e.tar.gz forums-d2cd24e8750729110e06e42b507fd89cadb9e51e.tar.bz2 forums-d2cd24e8750729110e06e42b507fd89cadb9e51e.tar.xz forums-d2cd24e8750729110e06e42b507fd89cadb9e51e.zip | |
Merge pull request #3090 from Nicofuma/ticket/13234
Ticket/13234
| -rw-r--r-- | phpBB/includes/session.php | 69 | 
1 files changed, 39 insertions, 30 deletions
| diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 4c13a4f558..a7bd3244ae 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -553,6 +553,45 @@ class session  		$method = basename(trim($config['auth_method']));  		include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx); +		$method = 'autologin_' . $method; +		if (function_exists($method)) +		{ +			$user_data = $method(); + +			if ($user_id === false || (isset($user_data['user_id']) && $user_id == $user_data['user_id'])) +			{ +				$this->data = $user_data; +			} + +			if (sizeof($this->data)) +			{ +				$this->cookie_data['k'] = ''; +				$this->cookie_data['u'] = $this->data['user_id']; +			} +		} + +		// If we're presented with an autologin key we'll join against it. +		// Else if we've been passed a user_id we'll grab data based on that +		if (isset($this->cookie_data['k']) && $this->cookie_data['k'] && $this->cookie_data['u'] && !sizeof($this->data)) +		{ +			$sql = 'SELECT u.* +				FROM ' . USERS_TABLE . ' u, ' . SESSIONS_KEYS_TABLE . ' k +				WHERE u.user_id = ' . (int) $this->cookie_data['u'] . ' +					AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ") +					AND k.user_id = u.user_id +					AND k.key_id = '" . $db->sql_escape(md5($this->cookie_data['k'])) . "'"; +			$result = $db->sql_query($sql); +			$user_data = $db->sql_fetchrow($result); + +			if ($user_id === false || (isset($user_data['user_id']) && $user_id == $user_data['user_id'])) +			{ +				$this->data = $user_data; +				$bot = false; +			} + +			$db->sql_freeresult($result); +		} +  		if ($user_id !== false && !sizeof($this->data))  		{  			$this->cookie_data['k'] = ''; @@ -567,36 +606,6 @@ class session  			$db->sql_freeresult($result);  			$bot = false;  		} -		else if (!$bot) -		{ -			$method = 'autologin_' . $method; -			if (function_exists($method)) -			{ -				$this->data = $method(); - -				if (sizeof($this->data)) -				{ -					$this->cookie_data['k'] = ''; -					$this->cookie_data['u'] = $this->data['user_id']; -				} -			} - -			// If we're presented with an autologin key we'll join against it. -			// Else if we've been passed a user_id we'll grab data based on that -			if (isset($this->cookie_data['k']) && $this->cookie_data['k'] && $this->cookie_data['u'] && !sizeof($this->data)) -			{ -				$sql = 'SELECT u.* -					FROM ' . USERS_TABLE . ' u, ' . SESSIONS_KEYS_TABLE . ' k -					WHERE u.user_id = ' . (int) $this->cookie_data['u'] . ' -						AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ") -						AND k.user_id = u.user_id -						AND k.key_id = '" . $db->sql_escape(md5($this->cookie_data['k'])) . "'"; -				$result = $db->sql_query($sql); -				$this->data = $db->sql_fetchrow($result); -				$db->sql_freeresult($result); -				$bot = false; -			} -		}  		// Bot user, if they have a SID in the Request URI we need to get rid of it  		// otherwise they'll index this page with the SID, duplicate content oh my! | 
