phpBB

Code Changes

File: includes/auth.php

  Unmodified   Added   Modified   Removed
Line 64Line 64
			$db->sql_freeresult($result);

$cache->put('_acl_options', $this->acl_options);

			$db->sql_freeresult($result);

$cache->put('_acl_options', $this->acl_options);

 
		}

if (!trim($userdata['user_permissions']))
{

			$this->acl_cache($userdata);
}

			$this->acl_cache($userdata);
}

		else if (!trim($userdata['user_permissions']))


























// Fill ACL array
$this->_fill_acl($userdata['user_permissions']);

// Verify bitstring length with options provided...
$renew = false;
$global_length = sizeof($this->acl_options['global']);
$local_length = sizeof($this->acl_options['local']);

// Specify comparing length (bitstring is padded to 31 bits)
$global_length = ($global_length % 31) ? ($global_length - ($global_length % 31) + 31) : $global_length;
$local_length = ($local_length % 31) ? ($local_length - ($local_length % 31) + 31) : $local_length;

// You thought we are finished now? Noooo... now compare them.
foreach ($this->acl as $forum_id => $bitstring)
{
if (($forum_id && strlen($bitstring) != $local_length) || (!$forum_id && strlen($bitstring) != $global_length))
{
$renew = true;
break;
}
}

// If a bitstring within the list does not match the options, we have a user with incorrect permissions set and need to renew them
if ($renew)

		{
$this->acl_cache($userdata);

		{
$this->acl_cache($userdata);

 
			$this->_fill_acl($userdata['user_permissions']);

		}


		}


		$user_permissions = explode("\n", $userdata['user_permissions']);












		return;
}

/**
* Fill ACL array with relevant bitstrings from user_permissions column
* @access private
*/
function _fill_acl($user_permissions)
{
$seq_cache = array();
$this->acl = array();
$user_permissions = explode("\n", $user_permissions);


foreach ($user_permissions as $f => $seq)
{


foreach ($user_permissions as $f => $seq)
{

Line 86Line 126

while ($subseq = substr($seq, $i, 6))
{


while ($subseq = substr($seq, $i, 6))
{

 
					if (isset($seq_cache[$subseq]))
{
$converted = $seq_cache[$subseq];
}
else
{
$converted = $seq_cache[$subseq] = str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT);
}


					// We put the original bitstring into the acl array

					// We put the original bitstring into the acl array

					$this->acl[$f] .= str_pad(base_convert($subseq, 36, 2), 31, 0, STR_PAD_LEFT);

					$this->acl[$f] .= $converted;

					$i += 6;
}
}
}

					$i += 6;
}
}
}


return;

 
	}

/**

	}

/**

Line 302Line 349

/**
* Get permission listing based on user_id/options/forum_ids


/**
* Get permission listing based on user_id/options/forum_ids

 
	*
* Be careful when using this function with permissions a_, m_, u_ and f_ !
* It may not work correctly. When a user group grants an a_* permission,
* e.g. a_foo, but the user's a_foo permission is set to "Never", then
* the user does not in fact have the a_ permission.
* But the user will still be listed as having the a_ permission.
*
* For more information see: http://tracker.phpbb.com/browse/PHPBB3-10252

	*/
function acl_get_list($user_id = false, $opts = false, $forum_id = false)
{

	*/
function acl_get_list($user_id = false, $opts = false, $forum_id = false)
{

Line 571Line 626

// Now grab group settings - non-role specific...
$sql_ary[] = 'SELECT ug.user_id, a.forum_id, a.auth_setting, a.auth_option_id' . $sql_opts_select . '


// Now grab group settings - non-role specific...
$sql_ary[] = 'SELECT ug.user_id, a.forum_id, a.auth_setting, a.auth_option_id' . $sql_opts_select . '

			FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug' . $sql_opts_from . '

			FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g' . $sql_opts_from . '

			WHERE a.auth_role_id = 0 ' .
(($sql_opts_from) ? 'AND a.auth_option_id = ao.auth_option_id ' : '') . '
AND a.group_id = ug.group_id

			WHERE a.auth_role_id = 0 ' .
(($sql_opts_from) ? 'AND a.auth_option_id = ao.auth_option_id ' : '') . '
AND a.group_id = ug.group_id

 
				AND g.group_id = ug.group_id

				AND ug.user_pending = 0

				AND ug.user_pending = 0

 
				AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1)

				' . (($sql_user) ? 'AND ug.' . $sql_user : '') . "
$sql_forum
$sql_opts";

// Now grab group settings - role specific...
$sql_ary[] = 'SELECT ug.user_id, a.forum_id, r.auth_setting, r.auth_option_id' . $sql_opts_select . '

				' . (($sql_user) ? 'AND ug.' . $sql_user : '') . "
$sql_forum
$sql_opts";

// Now grab group settings - role specific...
$sql_ary[] = 'SELECT ug.user_id, a.forum_id, r.auth_setting, r.auth_option_id' . $sql_opts_select . '

			FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . ACL_ROLES_DATA_TABLE . ' r' . $sql_opts_from . '

			FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g, ' . ACL_ROLES_DATA_TABLE . ' r' . $sql_opts_from . '

			WHERE a.auth_role_id = r.role_id ' .
(($sql_opts_from) ? 'AND r.auth_option_id = ao.auth_option_id ' : '') . '
AND a.group_id = ug.group_id

			WHERE a.auth_role_id = r.role_id ' .
(($sql_opts_from) ? 'AND r.auth_option_id = ao.auth_option_id ' : '') . '
AND a.group_id = ug.group_id

 
				AND g.group_id = ug.group_id

				AND ug.user_pending = 0

				AND ug.user_pending = 0

 
				AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1)

				' . (($sql_user) ? 'AND ug.' . $sql_user : '') . "
$sql_forum
$sql_opts";

				' . (($sql_user) ? 'AND ug.' . $sql_user : '') . "
$sql_forum
$sql_opts";

Line 788Line 847

// Now grab group-specific permission settings
$sql = 'SELECT a.forum_id, a.auth_option_id, a.auth_role_id, a.auth_setting


// Now grab group-specific permission settings
$sql = 'SELECT a.forum_id, a.auth_option_id, a.auth_role_id, a.auth_setting

			FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug

			FROM ' . ACL_GROUPS_TABLE . ' a, ' . USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g

			WHERE a.group_id = ug.group_id

			WHERE a.group_id = ug.group_id

 
				AND g.group_id = ug.group_id

				AND ug.user_pending = 0

				AND ug.user_pending = 0

 
				AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1)

				AND ug.user_id = ' . $user_id;
$result = $db->sql_query($sql);


				AND ug.user_id = ' . $user_id;
$result = $db->sql_query($sql);


Line 855Line 916
		$method = 'login_' . $method;
if (function_exists($method))
{

		$method = 'login_' . $method;
if (function_exists($method))
{

			$login = $method($username, $password);

			$login = $method($username, $password, $user->ip, $user->browser, $user->forwarded_for);


// If the auth module wants us to create an empty profile do so and then treat the status as LOGIN_SUCCESS
if ($login['status'] == LOGIN_SUCCESS_CREATE_PROFILE)


// If the auth module wants us to create an empty profile do so and then treat the status as LOGIN_SUCCESS
if ($login['status'] == LOGIN_SUCCESS_CREATE_PROFILE)