merge revisions #r8384, #r8387, #r8388, #r8389 and #r8390

git-svn-id: file:///svn/phpbb/trunk@8391 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2008-02-23 14:23:34 +00:00
parent 6dc85449c1
commit 2cedbbac09
30 changed files with 442 additions and 335 deletions

View file

@ -184,7 +184,7 @@ function adm_page_footer($copyright_html = true)
{
global $base_memory_usage;
$memory_usage -= $base_memory_usage;
$memory_usage = ($memory_usage >= 1048576) ? round((round($memory_usage / 1048576 * 100) / 100), 2) . ' ' . $user->lang['MB'] : (($memory_usage >= 1024) ? round((round($memory_usage / 1024 * 100) / 100), 2) . ' ' . $user->lang['KB'] : $memory_usage . ' ' . $user->lang['BYTES']);
$memory_usage = get_formatted_filesize($memory_usage);
$debug_output .= ' | Memory Usage: ' . $memory_usage;
}

View file

@ -77,7 +77,7 @@
<option value="{tables.TABLE}">{tables.TABLE}</option>
<!-- END tables -->
</select></dd>
<dd><a href="#" onclick="selector(true)">{L_SELECT_ALL}</a> :: <a href="#" onclick="selector(false)">{L_DESELECT_ALL}</a></dd>
<dd><a href="#" onclick="selector(true); return false;">{L_SELECT_ALL}</a> :: <a href="#" onclick="selector(false); return false;">{L_DESELECT_ALL}</a></dd>
</dl>
<p class="submit-buttons">

View file

@ -110,8 +110,8 @@
<li>[Fix] Use HTTP_HOST in favor of SERVER_NAME for determining server url for redirection and installation (Bug #19955)</li>
<li>[Fix] Removing s_watching_img from watch_topic_forum() function (Bug #20445)</li>
<li>[Fix] Changing order for post review if more than one post affected (Bug #15249)</li>
<li>[Fix] Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479)</li>
<li>[Fix] Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738)</li>
<li>[Fix] Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479, #20795, #21095, #21405, #21715, #21725, #21755, #21865, #15689)</li>
<li>[Fix] Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738, #19725)</li>
<li>[Fix] Tiny code fixes (Bug #20165, #20025, #19795, #14804)</li>
<li>[Fix] Prepend phpbb_root_path to ranks path for displaying ranks (Bug #19075)</li>
<li>[Fix] Allow forum notifications if topic notifications are disabled but forum notifications enabled (Bug #14765)</li>
@ -121,6 +121,14 @@
<li>[Fix] Correctly delete unapproved posts without deleting the topic (Bug #15120)</li>
<li>[Fix] Respect signature permissions in posting (Bug #16029)</li>
<li>[Fix] Users allowed to resign only from open and freely open groups (Bug #19355)</li>
<li>[Fix] Assign a last viewed date to converted topics (Bug #16565)</li>
<li>[Fix] Many minor and/or cosmetic fixes (Including, but not limited to: #21315, #18575, #18435, #21215)</li>
<li>[Feature] New option to hide the entire list of subforums on listforums</li>
<li>[Fix] Custom BBCode {EMAIL}-Token usage (Bug #21155)</li>
<li>[Fix] Do not rely on parameter returned by unlink() for verifying cache directory write permission (Bug #19565)</li>
<li>[Change] Use correct string for filesize (MiB instead of MB for example)</li>
<li>[Change] Remove left join for query used to retrieve already assigned users and groups within permission panel (Bug #20235)</li>
</ul>
<a name="v30rc8"></a><h3>1.i. Changes since 3.0.RC8</h3>

View file

@ -281,9 +281,9 @@
<a name="update_patch"></a><h3>4.iii. Patch file</h3>
<p>The patch file package is for those wanting to update through the patch application, and being compfortable with it.</p>
<p>The patch file package is for those wanting to update through the patch application, and being comfortable with it.</p>
<p>The patch file is one solution for those with many Modifications (MODs) or other changes who do not want to re-add them back to all the changed files if they use the method explained above. To use this you will need command line access to a standard UNIX type <strong>patch</strong> application. If you do not have access to such an application but still want to use this update approach, we strongly recommend the <a href="update_auto">Automatic update package</a> explained below. It is also the preferred update method.</p>
<p>The patch file is one solution for those with many Modifications (MODs) or other changes who do not want to re-add them back to all the changed files if they use the method explained above. To use this you will need command line access to a standard UNIX type <strong>patch</strong> application. If you do not have access to such an application but still want to use this update approach, we strongly recommend the <a href="#update_auto">Automatic update package</a> explained below. It is also the preferred update method.</p>
<p>A number of patch files are provided to allow you to update from previous stable releases. Select the correct patch, e.g. if your current version is 3.0.0 you need the phpBB-3.0.0_to_3.0.1.patch file. Place the correct patch in the parent directory containing the phpBB3 core files (i.e. index.php, viewforum.php, etc.). With this done you should run the following command: <strong>patch -cl -d [PHPBB DIRECTORY] -p1 &lt; [PATCH NAME]</strong> (where PHPBB DIRECTORY is the directory name your phpBB Installation resides in, for example phpBB3, and where PATCH NAME is the relevant filename of the selected patch file). This should complete quickly, hopefully without any HUNK FAILED comments.</p>
@ -369,7 +369,7 @@
<p><strong>Password conversion</strong> Due to the utf-8 based handling of passwords in phpBB3, it is not always possible to transfer all passwords. For passwords "lost in translation" the easiest workaround is to use the "forgotten password" function.</p>
<p><strong>Path to your former board</strong> The converter expects the relative path to your old board's files. So, -for instance - if the new board is located at <code>http://www.yourdomain.com/forum</code> and the phpBB3 is located at <code>http://www.yourdomain.com/phpBB3</code>, then the correct value would be <code>../forum</code>. Note that the webserver user must be able to access the source installation's files.</p>
<p><strong>Path to your former board</strong> The converter expects the relative path to your old board's files. So, - for instance - if the old board is located at <code>http://www.yourdomain.com/forum</code> and the phpBB3 installation is located at <code>http://www.yourdomain.com/phpBB3</code>, then the correct value would be <code>../forum</code>. Note that the webserver user must be able to access the source installation's files.</p>
<p><strong>Missing images</strong> If your default board language's language pack does not include all images, then some images might be missing in your installation. Always use a complete language pack as default language.</p>

View file

@ -110,7 +110,7 @@
<p>If entered with tabs (replace the {TAB}) both equal signs need to be on the same column.</p>
<h3>Linefeeds:</h3>
<p>Ensure that your editor is saving files in the UNIX format. This means lines are terminated with a newline, not with a CR/LF combo as they are on Win32, or whatever the Mac uses. Any decent editor should be able to do this, but it might not always be the default. Know your editor. If you want advice on Windows text editors, just ask one of the developers. Some of them do their editing on Win32.</p>
<p>Ensure that your editor is saving files in the UNIX (LF) line ending format. This means that lines are terminated with a newline, not with Windows Line endings (CR/LF combo) as they are on Win32 or Classic Mac (CR) Line endings. Any decent editor should be able to do this, but it might not always be the default setting. Know your editor. If you want advice for an editor for your Operating System, just ask one of the developers. Some of them do their editing on Win32.
<a name="fileheader"></a><h3>1.ii. File Header</h3>

View file

@ -306,7 +306,7 @@ class acm
if ($var_name[0] === '_')
{
$this->remove_file($this->cache_dir . 'data' . $var_name . ".$phpEx");
$this->remove_file($this->cache_dir . 'data' . $var_name . ".$phpEx", true);
}
else if (isset($this->vars[$var_name]))
{
@ -369,7 +369,7 @@ class acm
}
else if ($expired)
{
$this->remove_file($this->cache_dir . 'sql_' . md5($query) . ".$phpEx");
$this->remove_file($this->cache_dir . 'sql_' . md5($query) . ".$phpEx", true);
return false;
}
@ -452,13 +452,15 @@ class acm
/**
* Removes/unlinks file
*/
private function remove_file($filename)
private function remove_file($filename, $check = false)
{
if (!@unlink($filename))
if ($check && !@is_writeable($this->cache_dir))
{
// E_USER_ERROR - not using language entry - intended.
trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR);
}
return @unlink($filename);
}
}

View file

@ -152,7 +152,7 @@ class acp_attachments
if (in_array($config_name, array('attachment_quota', 'max_filesize', 'max_filesize_pm')))
{
$size_var = request_var($config_name, '');
$this->new_config[$config_name] = $config_value = ($size_var == 'kb') ? round($config_value * 1024) : (($size_var == 'mb') ? round($config_value * 1048576) : $config_value);
$this->new_config[$config_name] = $config_value = ($size_var == 'kb') ? ($config_value << 10) : (($size_var == 'mb') ? ($config_value << 20) : $config_value);
}
if ($submit)
@ -507,7 +507,7 @@ class acp_attachments
$allowed_forums = request_var('allowed_forums', array(0));
$allow_in_pm = (isset($_POST['allow_in_pm'])) ? true : false;
$max_filesize = request_var('max_filesize', 0);
$max_filesize = ($size_select == 'kb') ? round($max_filesize * 1024) : (($size_select == 'mb') ? round($max_filesize * 1048576) : $max_filesize);
$max_filesize = ($size_select == 'kb') ? ($max_filesize << 10) : (($size_select == 'mb') ? ($max_filesize << 20) : $max_filesize);
$allow_group = (isset($_POST['allow_group'])) ? true : false;
if ($max_filesize == $config['max_filesize'])
@ -680,8 +680,7 @@ class acp_attachments
}
$size_format = ($ext_group_row['max_filesize'] >= 1048576) ? 'mb' : (($ext_group_row['max_filesize'] >= 1024) ? 'kb' : 'b');
$ext_group_row['max_filesize'] = ($ext_group_row['max_filesize'] >= 1048576) ? round($ext_group_row['max_filesize'] / 1048576 * 100) / 100 : (($ext_group_row['max_filesize'] >= 1024) ? round($ext_group_row['max_filesize'] / 1024 * 100) / 100 : $ext_group_row['max_filesize']);
$ext_group_row['max_filesize'] = get_formatted_filesize($ext_group_row['max_filesize'], false);
$img_path = $config['upload_icons_path'];
@ -1007,11 +1006,8 @@ class acp_attachments
while ($row = $db->sql_fetchrow($result))
{
$size_lang = ($row['filesize'] >= 1048576) ? $user->lang['MB'] : (($row['filesize'] >= 1024) ? $user->lang['KB'] : $user->lang['BYTES']);
$row['filesize'] = ($row['filesize'] >= 1048576) ? round((round($row['filesize'] / 1048576 * 100) / 100), 2) : (($row['filesize'] >= 1024) ? round((round($row['filesize'] / 1024 * 100) / 100), 2) : $row['filesize']);
$template->assign_block_vars('orphan', array(
'FILESIZE' => $row['filesize'] . ' ' . $size_lang,
'FILESIZE' => get_formatted_filesize($row['filesize']),
'FILETIME' => $user->format_date($row['filetime']),
'REAL_FILENAME' => basename($row['real_filename']),
'PHYSICAL_FILENAME' => basename($row['physical_filename']),
@ -1417,7 +1413,7 @@ class acp_attachments
{
// Determine size var and adjust the value accordingly
$size_var = ($value >= 1048576) ? 'mb' : (($value >= 1024) ? 'kb' : 'b');
$value = ($value >= 1048576) ? round($value / 1048576 * 100) / 100 : (($value >= 1024) ? round($value / 1024 * 100) / 100 : $value);
$value = get_formatted_filesize($value, false);
return '<input type="text" id="' . $key . '" size="8" maxlength="15" name="config[' . $key . ']" value="' . $value . '" /> <select name="' . $key . '">' . size_select_options($size_var) . '</select>';
}

View file

@ -312,7 +312,7 @@ class acp_bbcodes
'!(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')!e' => "\$this->bbcode_specialchars('$1')"
),
'EMAIL' => array(
'!([a-z0-9]+[a-z0-9\-\._]*@(?:(?:[0-9]{1,3}\.){3,5}[0-9]{1,3}|[a-z0-9]+[a-z0-9\-\._]*\.[a-z]+))!i' => "\$this->bbcode_specialchars('$1')"
'!(' . get_preg_expression('email') . ')!ie' => "\$this->bbcode_specialchars('$1')"
),
'TEXT' => array(
'!(.*?)!es' => "str_replace(array(\"\\r\\n\", '\\\"', '\\'', '(', ')'), array(\"\\n\", '\"', '&#39;', '&#40;', '&#41;'), trim('\$1'))"
@ -334,7 +334,7 @@ class acp_bbcodes
$sp_tokens = array(
'URL' => '(?i)((?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('url')) . ')|(?:' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('www_url')) . '))(?-i)',
'LOCAL_URL' => '(?i)(' . str_replace(array('!', '\#'), array('\!', '#'), get_preg_expression('relative_url')) . ')(?-i)',
'EMAIL' => '([a-zA-Z0-9]+[a-zA-Z0-9\-\._]*@(?:(?:[0-9]{1,3}\.){3,5}[0-9]{1,3}|[a-zA-Z0-9]+[a-zA-Z0-9\-\._]*\.[a-zA-Z]+))',
'EMAIL' => '(' . get_preg_expression('email') . ')',
'TEXT' => '(.*?)',
'SIMPLETEXT' => '([a-zA-Z0-9-+.,_ ]+)',
'IDENTIFIER' => '([a-zA-Z0-9-_]+)',

View file

@ -307,8 +307,8 @@ class acp_main
$users_per_day = sprintf('%.2f', $total_users / $boarddays);
$files_per_day = sprintf('%.2f', $total_files / $boarddays);
$upload_dir_size = ($config['upload_dir_size'] >= 1048576) ? sprintf('%.2f ' . $user->lang['MB'], ($config['upload_dir_size'] / 1048576)) : (($config['upload_dir_size'] >= 1024) ? sprintf('%.2f ' . $user->lang['KB'], ($config['upload_dir_size'] / 1024)) : sprintf('%.2f ' . $user->lang['BYTES'], $config['upload_dir_size']));
$upload_dir_size = get_formatted_filesize($config['upload_dir_size']);
$avatar_dir_size = 0;
if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path']))
@ -322,10 +322,7 @@ class acp_main
}
closedir($avatar_dir);
// This bit of code translates the avatar directory size into human readable format
// Borrowed the code from the PHP.net annoted manual, origanally written by:
// Jesse (jesse@jess.on.ca)
$avatar_dir_size = ($avatar_dir_size >= 1048576) ? sprintf('%.2f ' . $user->lang['MB'], ($avatar_dir_size / 1048576)) : (($avatar_dir_size >= 1024) ? sprintf('%.2f ' . $user->lang['KB'], ($avatar_dir_size / 1024)) : sprintf('%.2f ' . $user->lang['BYTES'], $avatar_dir_size));
$avatar_dir_size = get_formatted_filesize($avatar_dir_size);
}
else
{

View file

@ -48,7 +48,7 @@ class acp_permissions
$this->tpl_name = 'permission_trace';
if ($user_id && isset($auth_admin->option_ids[$permission]) && $auth->acl_get('a_viewauth'))
if ($user_id && isset($auth_admin->acl_options['id'][$permission]) && $auth->acl_get('a_viewauth'))
{
$this->page_title = sprintf($user->lang['TRACE_PERMISSION'], $user->lang['acl_' . $permission]['lang']);
$this->permission_trace($user_id, $forum_id, $permission);
@ -124,7 +124,7 @@ class acp_permissions
$forum_id = array();
while ($row = $db->sql_fetchrow($result))
{
$forum_id[] = $row['forum_id'];
$forum_id[] = (int) $row['forum_id'];
}
$db->sql_freeresult($result);
}
@ -133,7 +133,7 @@ class acp_permissions
$forum_id = array();
foreach (get_forum_branch($subforum_id, 'children') as $row)
{
$forum_id[] = $row['forum_id'];
$forum_id[] = (int) $row['forum_id'];
}
}
@ -598,7 +598,7 @@ class acp_permissions
$ids = array();
while ($row = $db->sql_fetchrow($result))
{
$ids[] = $row[$sql_id];
$ids[] = (int) $row[$sql_id];
}
$db->sql_freeresult($result);
}
@ -1117,31 +1117,51 @@ class acp_permissions
global $db, $user;
$sql_forum_id = ($permission_scope == 'global') ? 'AND a.forum_id = 0' : ((sizeof($forum_id)) ? 'AND ' . $db->sql_in_set('a.forum_id', $forum_id) : 'AND a.forum_id <> 0');
$sql_permission_option = ' AND o.auth_option ' . $db->sql_like_expression($permission_type . $db->any_char);
$sql = $db->sql_build_query('SELECT_DISTINCT', array(
'SELECT' => 'u.username, u.username_clean, u.user_regdate, u.user_id',
'FROM' => array(
USERS_TABLE => 'u',
ACL_OPTIONS_TABLE => 'o',
ACL_USERS_TABLE => 'a'
),
// Permission options are only able to be a permission set... therefore we will pre-fetch the possible options and also the possible roles
$option_ids = $role_ids = array();
'LEFT_JOIN' => array(
array(
'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'),
'ON' => 'a.auth_role_id = r.role_id'
)
),
$sql = 'SELECT auth_option_id
FROM ' . ACL_OPTIONS_TABLE . '
WHERE auth_option ' . $db->sql_like_expression($permission_type . $db->any_char);
$result = $db->sql_query($sql);
'WHERE' => "(a.auth_option_id = o.auth_option_id OR r.auth_option_id = o.auth_option_id)
$sql_permission_option
while ($row = $db->sql_fetchrow($result))
{
$option_ids[] = (int) $row['auth_option_id'];
}
$db->sql_freeresult($result);
if (sizeof($option_ids))
{
$sql = 'SELECT DISTINCT role_id
FROM ' . ACL_ROLES_DATA_TABLE . '
WHERE ' . $db->sql_in_set('auth_option_id', $option_ids);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$role_ids[] = (int) $row['role_id'];
}
$db->sql_freeresult($result);
}
if (sizeof($option_ids) && sizeof($role_ids))
{
$sql_where = 'AND (' . $db->sql_in_set('a.auth_option_id', $option_ids) . ' OR ' . $db->sql_in_set('a.auth_role_id', $role_ids) . ')';
}
else
{
$sql_where = 'AND ' . $db->sql_in_set('a.auth_option_id', $option_ids);
}
// Not ideal, due to the filesort, non-use of indexes, etc.
$sql = 'SELECT DISTINCT u.user_id, u.username
FROM ' . USERS_TABLE . ' u, ' . ACL_USERS_TABLE . " a
WHERE u.user_id = a.user_id
$sql_forum_id
AND u.user_id = a.user_id",
'ORDER_BY' => 'u.username_clean, u.user_regdate ASC'
));
$sql_where
ORDER BY u.username_clean, u.user_regdate ASC";
$result = $db->sql_query($sql);
$s_defined_user_options = '';
@ -1153,29 +1173,12 @@ class acp_permissions
}
$db->sql_freeresult($result);
$sql = $db->sql_build_query('SELECT_DISTINCT', array(
'SELECT' => 'g.group_type, g.group_name, g.group_id',
'FROM' => array(
GROUPS_TABLE => 'g',
ACL_OPTIONS_TABLE => 'o',
ACL_GROUPS_TABLE => 'a'
),
'LEFT_JOIN' => array(
array(
'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'),
'ON' => 'a.auth_role_id = r.role_id'
)
),
'WHERE' => "(a.auth_option_id = o.auth_option_id OR r.auth_option_id = o.auth_option_id)
$sql_permission_option
$sql = 'SELECT DISTINCT g.group_type, g.group_name, g.group_id
FROM ' . GROUPS_TABLE . ' g, ' . ACL_GROUPS_TABLE . " a
WHERE g.group_id = a.group_id
$sql_forum_id
AND g.group_id = a.group_id",
'ORDER_BY' => 'g.group_type DESC, g.group_name ASC'
));
$sql_where
ORDER BY g.group_type DESC, g.group_name ASC";
$result = $db->sql_query($sql);
$s_defined_group_options = '';

View file

@ -1003,7 +1003,7 @@ parse_css_file = {PARSE_CSS_FILE}
'CACHED' => $user->format_date(filemtime("{$phpbb_root_path}cache/$filename")),
'FILENAME' => $file,
'FILESIZE' => sprintf('%.1f KB', filesize("{$phpbb_root_path}cache/$filename") / 1024),
'FILESIZE' => sprintf('%.1f ' . $user->lang['KIB'], filesize("{$phpbb_root_path}cache/$filename") / 1024),
'MODIFIED' => $user->format_date((!$template_row['template_storedb']) ? filemtime("{$phpbb_root_path}styles/{$template_row['template_path']}/template/$tpl_file.html") : $filemtime[$file . '.html']))
);
}

View file

@ -1745,7 +1745,7 @@ class acp_users
'REAL_FILENAME' => $row['real_filename'],
'COMMENT' => nl2br($row['attach_comment']),
'EXTENSION' => $row['extension'],
'SIZE' => ($row['filesize'] >= 1048576) ? ($row['filesize'] >> 20) . ' ' . $user->lang['MB'] : (($row['filesize'] >= 1024) ? ($row['filesize'] >> 10) . ' ' . $user->lang['KB'] : $row['filesize'] . ' ' . $user->lang['BYTES']),
'SIZE' => get_formatted_filesize($row['filesize']),
'DOWNLOAD_COUNT' => $row['download_count'],
'POST_TIME' => $user->format_date($row['filetime']),
'TOPIC_TITLE' => ($row['in_message']) ? $row['message_title'] : $row['topic_title'],

View file

@ -22,8 +22,6 @@ if (!defined('IN_PHPBB'))
*/
class auth_admin extends auth
{
var $option_ids = array();
/**
* Init auth settings
*/
@ -33,7 +31,7 @@ class auth_admin extends auth
if (($this->acl_options = $cache->get('_acl_options')) === false)
{
$sql = 'SELECT auth_option, is_global, is_local
$sql = 'SELECT auth_option_id, auth_option, is_global, is_local
FROM ' . ACL_OPTIONS_TABLE . '
ORDER BY auth_option_id';
$result = $db->sql_query($sql);
@ -51,25 +49,14 @@ class auth_admin extends auth
{
$this->acl_options['local'][$row['auth_option']] = $local++;
}
$this->acl_options['id'][$row['auth_option']] = (int) $row['auth_option_id'];
$this->acl_options['option'][(int) $row['auth_option_id']] = $row['auth_option'];
}
$db->sql_freeresult($result);
$cache->put('_acl_options', $this->acl_options);
}
if (!sizeof($this->option_ids))
{
$sql = 'SELECT auth_option_id, auth_option
FROM ' . ACL_OPTIONS_TABLE;
$result = $db->sql_query($sql);
$this->option_ids = array();
while ($row = $db->sql_fetchrow($result))
{
$this->option_ids[$row['auth_option']] = $row['auth_option_id'];
}
$db->sql_freeresult($result);
}
}
/**
@ -126,7 +113,7 @@ class auth_admin extends auth
while ($row = $db->sql_fetchrow($result))
{
$forum_ids[] = $row['forum_id'];
$forum_ids[] = (int) $row['forum_id'];
}
$db->sql_freeresult($result);
}
@ -774,7 +761,7 @@ class auth_admin extends auth
$this->acl_clear_prefetch();
// Because we just changed the options and also purged the options cache, we instantly update/regenerate it for later calls to succeed.
$this->option_ids = $this->acl_options = array();
$this->acl_options = array();
$this->__construct();
return true;
@ -812,7 +799,7 @@ class auth_admin extends auth
$flag = substr($flag, 0, strpos($flag, '_') + 1);
// This ID (the any-flag) is set if one or more permissions are true...
$any_option_id = (int) $this->option_ids[$flag];
$any_option_id = (int) $this->acl_options['id'][$flag];
// Remove any-flag from auth ary
if (isset($auth[$flag]))
@ -824,7 +811,7 @@ class auth_admin extends auth
$auth_option_ids = array((int)$any_option_id);
foreach ($auth as $auth_option => $auth_setting)
{
$auth_option_ids[] = (int) $this->option_ids[$auth_option];
$auth_option_ids[] = (int) $this->acl_options['id'][$auth_option];
}
$sql = "DELETE FROM $table
@ -887,7 +874,7 @@ class auth_admin extends auth
{
foreach ($auth as $auth_option => $setting)
{
$auth_option_id = (int) $this->option_ids[$auth_option];
$auth_option_id = (int) $this->acl_options['id'][$auth_option];
if ($setting != ACL_NO)
{
@ -943,7 +930,7 @@ class auth_admin extends auth
$sql_ary = array();
foreach ($auth as $auth_option => $setting)
{
$auth_option_id = (int) $this->option_ids[$auth_option];
$auth_option_id = (int) $this->acl_options['id'][$auth_option];
if ($setting != ACL_NO)
{
@ -960,7 +947,7 @@ class auth_admin extends auth
{
$sql_ary[] = array(
'role_id' => (int) $role_id,
'auth_option_id' => (int) $this->option_ids[$flag],
'auth_option_id' => (int) $this->acl_options['id'][$flag],
'auth_setting' => ACL_NEVER
);
}
@ -1237,13 +1224,8 @@ class auth_admin extends auth
return false;
}
$hold_ary = $this->acl_raw_data($from_user_id, false, false);
$hold_ary = $this->acl_raw_data_single_user($from_user_id);
if (isset($hold_ary[$from_user_id]))
{
$hold_ary = $hold_ary[$from_user_id];
}
// Key 0 in $hold_ary are global options, all others are forum_ids
// We disallow copying admin permissions
@ -1251,12 +1233,12 @@ class auth_admin extends auth
{
if (strpos($opt, 'a_') === 0)
{
$hold_ary[0][$opt] = ACL_NEVER;
$hold_ary[0][$this->acl_options['id'][$opt]] = ACL_NEVER;
}
}
// Force a_switchperm to be allowed
$hold_ary[0]['a_switchperm'] = ACL_YES;
$hold_ary[0][$this->acl_options['id']['a_switchperm']] = ACL_YES;
$user_permissions = $this->build_bitstring($hold_ary);

View file

@ -39,7 +39,7 @@ class auth
if (($this->acl_options = $cache->get('_acl_options')) === false)
{
$sql = 'SELECT auth_option, is_global, is_local
$sql = 'SELECT auth_option_id, auth_option, is_global, is_local
FROM ' . ACL_OPTIONS_TABLE . '
ORDER BY auth_option_id';
$result = $db->sql_query($sql);
@ -57,6 +57,9 @@ class auth
{
$this->acl_options['local'][$row['auth_option']] = $local++;
}
$this->acl_options['id'][$row['auth_option']] = (int) $row['auth_option_id'];
$this->acl_options['option'][(int) $row['auth_option_id']] = $row['auth_option'];
}
$db->sql_freeresult($result);
@ -300,7 +303,14 @@ class auth
*/
public function acl_get_list($user_id = false, $opts = false, $forum_id = false)
{
$hold_ary = $this->acl_raw_data($user_id, $opts, $forum_id);
if ($user_id !== false && !is_array($user_id) && $opts === false && $forum_id === false)
{
$hold_ary = array($user_id => $this->acl_raw_data_single_user($user_id));
}
else
{
$hold_ary = $this->acl_raw_data($user_id, $opts, $forum_id);
}
$auth_ary = array();
foreach ($hold_ary as $user_id => $forum_ary)
@ -330,12 +340,7 @@ class auth
// Empty user_permissions
$userdata['user_permissions'] = '';
$hold_ary = $this->acl_raw_data($userdata['user_id'], false, false);
if (isset($hold_ary[$userdata['user_id']]))
{
$hold_ary = $hold_ary[$userdata['user_id']];
}
$hold_ary = $this->acl_raw_data_single_user($userdata['user_id']);
// Key 0 in $hold_ary are global options, all others are forum_ids
@ -346,42 +351,11 @@ class auth
{
if (strpos($opt, 'a_') === 0)
{
$hold_ary[0][$opt] = ACL_YES;
$hold_ary[0][$this->acl_options['id'][$opt]] = ACL_YES;
}
}
}
// Sometimes, it can happen $hold_ary holding forums which do not exist.
// Since this function is not called that often (we are caching the data) we check for this inconsistency.
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', array_keys($hold_ary), false, true);
$result = $db->sql_query($sql);
$forum_ids = (isset($hold_ary[0])) ? array(0) : array();
while ($row = $db->sql_fetchrow($result))
{
$forum_ids[] = $row['forum_id'];
}
$db->sql_freeresult($result);
// Now determine forums which do not exist and remove the unneeded information (for modding purposes it is clearly the wrong place. ;))
$missing_forums = array_diff(array_keys($hold_ary), $forum_ids);
if (sizeof($missing_forums))
{
foreach ($missing_forums as $forum_id)
{
unset($hold_ary[$forum_id]);
}
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $missing_forums);
$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $missing_forums);
$db->sql_query($sql);
}
$hold_str = $this->build_bitstring($hold_ary);
if ($hold_str)
@ -418,15 +392,15 @@ class auth
$bitstring = array();
foreach ($this->acl_options[$ary_key] as $opt => $id)
{
if (isset($auth_ary[$opt]))
if (isset($auth_ary[$this->acl_options['id'][$opt]]))
{
$bitstring[$id] = $auth_ary[$opt];
$bitstring[$id] = $auth_ary[$this->acl_options['id'][$opt]];
$option_key = substr($opt, 0, strpos($opt, '_') + 1);
// If one option is allowed, the global permission for this option has to be allowed too
// example: if the user has the a_ permission this means he has one or more a_* permissions
if ($auth_ary[$opt] == ACL_YES && (!isset($bitstring[$this->acl_options[$ary_key][$option_key]]) || $bitstring[$this->acl_options[$ary_key][$option_key]] == ACL_NEVER))
if ($auth_ary[$this->acl_options['id'][$opt]] == ACL_YES && (!isset($bitstring[$this->acl_options[$ary_key][$option_key]]) || $bitstring[$this->acl_options[$ary_key][$option_key]] == ACL_NEVER))
{
$bitstring[$this->acl_options[$ary_key][$option_key]] = ACL_YES;
}
@ -464,8 +438,31 @@ class auth
*/
public function acl_clear_prefetch($user_id = false)
{
global $db;
global $db, $cache;
// Rebuild options cache
$cache->destroy('_role_cache');
$sql = 'SELECT *
FROM ' . ACL_ROLES_DATA_TABLE . '
ORDER BY role_id ASC';
$result = $db->sql_query($sql);
$this->role_cache = array();
while ($row = $db->sql_fetchrow($result))
{
$this->role_cache[$row['role_id']][$row['auth_option_id']] = (int) $row['auth_setting'];
}
$db->sql_freeresult($result);
foreach ($this->role_cache as $role_id => $role_options)
{
$this->role_cache[$role_id] = serialize($role_options);
}
$cache->put('_role_cache', $this->role_cache);
// Now empty user permissions
$where_sql = '';
if ($user_id !== false)
@ -528,103 +525,35 @@ class auth
$sql_user = ($user_id !== false) ? ((!is_array($user_id)) ? 'user_id = ' . (int) $user_id : $db->sql_in_set('user_id', array_map('intval', $user_id))) : '';
$sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : '';
$sql_opts = '';
$sql_opts = $sql_opts_select = $sql_opts_from = '';
$hold_ary = array();
if ($opts !== false)
{
$sql_opts_select = ', ao.auth_option';
$sql_opts_from = ', ' . ACL_OPTIONS_TABLE . ' ao';
$this->build_auth_option_statement('ao.auth_option', $opts, $sql_opts);
}
$hold_ary = array();
$sql_ary = array();
// First grab user settings ... each user has only one setting for each
// option ... so we shouldn't need any ACL_NEVER checks ... he says ...
// Grab assigned roles...
$sql = $db->sql_build_query('SELECT', array(
'SELECT' => 'ao.auth_option, a.auth_role_id, r.auth_setting as role_auth_setting, a.user_id, a.forum_id, a.auth_setting',
'FROM' => array(
ACL_OPTIONS_TABLE => 'ao',
ACL_USERS_TABLE => 'a'
),
'LEFT_JOIN' => array(
array(
'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'),
'ON' => 'a.auth_role_id = r.role_id'
)
),
'WHERE' => '(ao.auth_option_id = a.auth_option_id OR ao.auth_option_id = r.auth_option_id)
' . (($sql_user) ? 'AND a.' . $sql_user : '') . "
// Grab non-role settings - user-specific
$sql_ary[] = 'SELECT a.user_id, a.forum_id, a.auth_setting, a.auth_option_id' . $sql_opts_select . '
FROM ' . ACL_USERS_TABLE . ' a' . $sql_opts_from . '
WHERE a.auth_role_id = 0 ' .
(($sql_opts_from) ? 'AND a.auth_option_id = ao.auth_option_id ' : '') .
(($sql_user) ? 'AND a.' . $sql_user : '') . "
$sql_forum
$sql_opts",
));
$result = $db->sql_query($sql);
$sql_opts";
while ($row = $db->sql_fetchrow($result))
{
$setting = ($row['auth_role_id']) ? $row['role_auth_setting'] : $row['auth_setting'];
$hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']] = $setting;
}
$db->sql_freeresult($result);
// Now grab group settings ... ACL_NEVER overrides ACL_YES so act appropriatley
$sql_ary[] = $db->sql_build_query('SELECT', array(
'SELECT' => 'ug.user_id, ao.auth_option, a.forum_id, a.auth_setting, a.auth_role_id, r.auth_setting as role_auth_setting',
'FROM' => array(
USER_GROUP_TABLE => 'ug',
ACL_OPTIONS_TABLE => 'ao',
ACL_GROUPS_TABLE => 'a'
),
'LEFT_JOIN' => array(
array(
'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'),
'ON' => 'a.auth_role_id = r.role_id'
)
),
'WHERE' => 'ao.auth_option_id = a.auth_option_id
AND a.group_id = ug.group_id
AND ug.user_pending = 0
' . (($sql_user) ? 'AND ug.' . $sql_user : '') . "
// Now the role settings - user-specific
$sql_ary[] = 'SELECT a.user_id, a.forum_id, r.auth_option_id, r.auth_setting, r.auth_option_id' . $sql_opts_select . '
FROM ' . ACL_USERS_TABLE . ' a, ' . 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 ' : '') .
(($sql_user) ? 'AND a.' . $sql_user : '') . "
$sql_forum
$sql_opts"
));
$sql_ary[] = $db->sql_build_query('SELECT', array(
'SELECT' => 'ug.user_id, a.forum_id, a.auth_setting, a.auth_role_id, r.auth_setting as role_auth_setting, ao.auth_option' ,
'FROM' => array(
ACL_OPTIONS_TABLE => 'ao'
),
'LEFT_JOIN' => array(
array(
'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'),
'ON' => 'r.auth_option_id = ao.auth_option_id'
),
array(
'FROM' => array(ACL_GROUPS_TABLE => 'a'),
'ON' => 'a.auth_role_id = r.role_id'
),
array(
'FROM' => array(USER_GROUP_TABLE => 'ug'),
'ON' => 'ug.group_id = a.group_id'
)
),
'WHERE' => 'ug.user_pending = 0
' . (($sql_user) ? 'AND ug.' . $sql_user : '') . "
$sql_forum
$sql_opts"
));
$sql_opts";
foreach ($sql_ary as $sql)
{
@ -632,25 +561,63 @@ class auth
while ($row = $db->sql_fetchrow($result))
{
$option = ($sql_opts_select) ? $row['auth_option'] : $this->acl_options['option'][$row['auth_option_id']];
$hold_ary[$row['user_id']][$row['forum_id']][$option] = $row['auth_setting'];
}
$db->sql_freeresult($result);
}
$sql_ary = array();
// 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 . '
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 ug.user_pending = 0
' . (($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 . '
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 ug.user_pending = 0
' . (($sql_user) ? 'AND ug.' . $sql_user : '') . "
$sql_forum
$sql_opts";
foreach ($sql_ary as $sql)
{
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$option = ($sql_opts_select) ? $row['auth_option'] : $this->acl_options['option'][$row['auth_option_id']];
// @todo: use the ref technique to reduce opcode generation
if (!isset($hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']]) || (isset($hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']]) && $hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']] != ACL_NEVER))
if (!isset($hold_ary[$row['user_id']][$row['forum_id']][$option]) || (isset($hold_ary[$row['user_id']][$row['forum_id']][$option]) && $hold_ary[$row['user_id']][$row['forum_id']][$option] != ACL_NEVER))
{
$setting = ($row['auth_role_id']) ? $row['role_auth_setting'] : $row['auth_setting'];
$hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']] = $setting;
// Check for existence of ACL_YES if an option got set to ACL_NEVER
if ($setting == ACL_NEVER)
$hold_ary[$row['user_id']][$row['forum_id']][$option] = $row['auth_setting'];
// If we detect ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again)
if ($row['auth_setting'] == ACL_NEVER)
{
$flag = substr($row['auth_option'], 0, strpos($row['auth_option'], '_') + 1);
$flag = substr($option, 0, strpos($option, '_') + 1);
if (isset($hold_ary[$row['user_id']][$row['forum_id']][$flag]) && $hold_ary[$row['user_id']][$row['forum_id']][$flag] == ACL_YES)
{
unset($hold_ary[$row['user_id']][$row['forum_id']][$flag]);
if (in_array(ACL_YES, $hold_ary[$row['user_id']][$row['forum_id']]))
/* if (in_array(ACL_YES, $hold_ary[$row['user_id']][$row['forum_id']]))
{
$hold_ary[$row['user_id']][$row['forum_id']][$flag] = ACL_YES;
}
*/
}
}
}
@ -672,45 +639,43 @@ class auth
$sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : '';
$sql_opts = '';
$hold_ary = $sql_ary = array();
if ($opts !== false)
{
$this->build_auth_option_statement('ao.auth_option', $opts, $sql_opts);
}
$hold_ary = array();
// Grab user settings...
$sql = $db->sql_build_query('SELECT', array(
'SELECT' => 'ao.auth_option, a.auth_role_id, r.auth_setting as role_auth_setting, a.user_id, a.forum_id, a.auth_setting',
'FROM' => array(
ACL_OPTIONS_TABLE => 'ao',
ACL_USERS_TABLE => 'a'
),
'LEFT_JOIN' => array(
array(
'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'),
'ON' => 'a.auth_role_id = r.role_id'
),
),
'WHERE' => '(ao.auth_option_id = a.auth_option_id OR ao.auth_option_id = r.auth_option_id)
' . (($sql_user) ? 'AND a.' . $sql_user : '') . "
// Grab user settings - non-role specific...
$sql_ary[] = 'SELECT a.user_id, a.forum_id, a.auth_setting, a.auth_option_id, ao.auth_option
FROM ' . ACL_USERS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . ' ao
WHERE a.auth_role_id = 0
AND a.auth_option_id = ao.auth_option_id ' .
(($sql_user) ? 'AND a.' . $sql_user : '') . "
$sql_forum
$sql_opts",
$sql_opts
ORDER BY a.forum_id, ao.auth_option";
'ORDER_BY' => 'a.forum_id, ao.auth_option'
));
$result = $db->sql_query($sql);
// Now the role settings - user-specific
$sql_ary[] = 'SELECT a.user_id, a.forum_id, r.auth_option_id, r.auth_setting, r.auth_option_id, ao.auth_option
FROM ' . ACL_USERS_TABLE . ' a, ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' ao
WHERE a.auth_role_id = r.role_id
AND r.auth_option_id = ao.auth_option_id ' .
(($sql_user) ? 'AND a.' . $sql_user : '') . "
$sql_forum
$sql_opts
ORDER BY a.forum_id, ao.auth_option";
while ($row = $db->sql_fetchrow($result))
foreach ($sql_ary as $sql)
{
$setting = ($row['auth_role_id']) ? $row['role_auth_setting'] : $row['auth_setting'];
$hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']] = $setting;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$hold_ary[$row['user_id']][$row['forum_id']][$row['auth_option']] = $row['auth_setting'];
}
$db->sql_freeresult($result);
}
$db->sql_freeresult($result);
return $hold_ary;
}
@ -726,49 +691,158 @@ class auth
$sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : '';
$sql_opts = '';
$hold_ary = $sql_ary = array();
if ($opts !== false)
{
$this->build_auth_option_statement('ao.auth_option', $opts, $sql_opts);
}
// Grab group settings - non-role specific...
$sql_ary[] = 'SELECT a.group_id, a.forum_id, a.auth_setting, a.auth_option_id, ao.auth_option
FROM ' . ACL_GROUPS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . ' ao
WHERE a.auth_role_id = 0
AND a.auth_option_id = ao.auth_option_id ' .
(($sql_group) ? 'AND a.' . $sql_group : '') . "
$sql_forum
$sql_opts
ORDER BY a.forum_id, ao.auth_option";
// Now grab group settings - role specific...
$sql_ary[] = 'SELECT a.group_id, a.forum_id, r.auth_setting, r.auth_option_id, ao.auth_option
FROM ' . ACL_GROUPS_TABLE . ' a, ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' ao
WHERE a.auth_role_id = r.role_id
AND r.auth_option_id = ao.auth_option_id ' .
(($sql_group) ? 'AND a.' . $sql_group : '') . "
$sql_forum
$sql_opts
ORDER BY a.forum_id, ao.auth_option";
foreach ($sql_ary as $sql)
{
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$hold_ary[$row['group_id']][$row['forum_id']][$row['auth_option']] = $row['auth_setting'];
}
$db->sql_freeresult($result);
}
return $hold_ary;
}
/**
* Get raw acl data based on user for caching user_permissions
* This function returns the same data as acl_raw_data(), but without the user id as the first key within the array.
*/
public function acl_raw_data_single_user($user_id)
{
global $db, $cache;
// Check if the role-cache is there
if (($this->role_cache = $cache->get('_role_cache')) === false)
{
$this->role_cache = array();
// We pre-fetch roles
$sql = 'SELECT *
FROM ' . ACL_ROLES_DATA_TABLE . '
ORDER BY role_id ASC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$this->role_cache[$row['role_id']][$row['auth_option_id']] = (int) $row['auth_setting'];
}
$db->sql_freeresult($result);
foreach ($this->role_cache as $role_id => $role_options)
{
$this->role_cache[$role_id] = serialize($role_options);
}
$cache->put('_role_cache', $this->role_cache);
}
$hold_ary = array();
// Grab group settings...
$sql = $db->sql_build_query('SELECT', array(
'SELECT' => 'a.group_id, ao.auth_option, a.forum_id, a.auth_setting, a.auth_role_id, r.auth_setting as role_auth_setting',
'FROM' => array(
ACL_OPTIONS_TABLE => 'ao',
ACL_GROUPS_TABLE => 'a'
),
'LEFT_JOIN' => array(
array(
'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'),
'ON' => 'a.auth_role_id = r.role_id'
),
),
'WHERE' => '(ao.auth_option_id = a.auth_option_id OR ao.auth_option_id = r.auth_option_id)
' . (($sql_group) ? 'AND a.' . $sql_group : '') . "
$sql_forum
$sql_opts",
'ORDER_BY' => 'a.forum_id, ao.auth_option'
));
// Grab user-specific permission settings
$sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting
FROM ' . ACL_USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$setting = ($row['auth_role_id']) ? $row['role_auth_setting'] : $row['auth_setting'];
$hold_ary[$row['group_id']][$row['forum_id']][$row['auth_option']] = $setting;
// If a role is assigned, assign all options included within this role. Else, only set this one option.
if ($row['auth_role_id'])
{
$hold_ary[$row['forum_id']] = (empty($hold_ary[$row['forum_id']])) ? unserialize($this->role_cache[$row['auth_role_id']]) : $hold_ary[$row['forum_id']] + unserialize($this->role_cache[$row['auth_role_id']]);
}
else
{
$hold_ary[$row['forum_id']][$row['auth_option_id']] = $row['auth_setting'];
}
}
$db->sql_freeresult($result);
// 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
WHERE a.group_id = ug.group_id
AND ug.user_pending = 0
AND ug.user_id = ' . $user_id;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if (!$row['auth_role_id'])
{
$this->_set_group_hold_ary($hold_ary[$row['forum_id']], $row['auth_option_id'], $row['auth_setting']);
}
else
{
foreach (unserialize($this->role_cache[$row['auth_role_id']]) as $option_id => $setting)
{
$this->_set_group_hold_ary($hold_ary[$row['forum_id']], $option_id, $setting);
}
}
}
$db->sql_freeresult($result);
return $hold_ary;
}
/**
* Private function snippet for setting a specific piece of the hold_ary
*/
private function _set_group_hold_ary(&$hold_ary, $option_id, $setting)
{
if (!isset($hold_ary[$option_id]) || (isset($hold_ary[$option_id]) && $hold_ary[$option_id] != ACL_NEVER))
{
$hold_ary[$option_id] = $setting;
// If we detect ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again)
if ($setting == ACL_NEVER)
{
$flag = substr($this->acl_options['option'][$option_id], 0, strpos($this->acl_options['option'][$option_id], '_') + 1);
$flag = (int) $this->acl_options['id'][$flag];
if (isset($hold_ary[$flag]) && $hold_ary[$flag] == ACL_YES)
{
unset($hold_ary[$flag]);
/* This is uncommented, because i suspect this being slightly wrong due to mixed permission classes being possible
if (in_array(ACL_YES, $hold_ary))
{
$hold_ary[$flag] = ACL_YES;
}*/
}
}
}
}
/**
* Authentication plug-ins is largely down to Sergey Kanareykin, our thanks to him.
*/

View file

@ -198,6 +198,26 @@ function unique_id($extra = 'c')
return substr($val, 4, 16);
}
/**
* Return formatted string for filesizes
*/
function get_formatted_filesize($bytes, $add_size_lang = true)
{
global $user;
if ($bytes >= pow(2, 20))
{
return ($add_size_lang) ? round($bytes / 1024 / 1024, 2) . ' ' . $user->lang['MIB'] : round($bytes / 1024 / 1024, 2);
}
if ($bytes >= pow(2, 10))
{
return ($add_size_lang) ? round($bytes / 1024, 2) . ' ' . $user->lang['KIB'] : round($bytes / 1024, 2);
}
return ($add_size_lang) ? ($bytes) . ' ' . $user->lang['BYTES'] : ($bytes);
}
/**
* Determine whether we are approaching the maximum execution time. Should be called once
* at the beginning of the script in which it's used.
@ -2643,7 +2663,7 @@ function get_preg_expression($mode)
switch ($mode)
{
case 'email':
return '[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*[a-z]+';
return '[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.(?:[a-z0-9\-]+\.)*[a-z]+';
break;
case 'bbcode_htm':
@ -3343,7 +3363,7 @@ function page_footer($run_cron = true)
{
global $base_memory_usage;
$memory_usage -= $base_memory_usage;
$memory_usage = ($memory_usage >= 1048576) ? round((round($memory_usage / 1048576 * 100) / 100), 2) . ' ' . $user->lang['MB'] : (($memory_usage >= 1024) ? round((round($memory_usage / 1024 * 100) / 100), 2) . ' ' . $user->lang['KB'] : $memory_usage . ' ' . $user->lang['BYTES']);
$memory_usage = get_formatted_filesize($memory_usage);
$debug_output .= ' | Memory Usage: ' . $memory_usage;
}

View file

@ -196,7 +196,7 @@ function size_select_options($size_compare)
{
global $user;
$size_types_text = array($user->lang['BYTES'], $user->lang['KB'], $user->lang['MB']);
$size_types_text = array($user->lang['BYTES'], $user->lang['KIB'], $user->lang['MIB']);
$size_types = array('b', 'kb', 'mb');
$s_size_options = '';
@ -2859,14 +2859,7 @@ function get_database_size()
break;
}
if ($database_size !== false)
{
$database_size = ($database_size >= 1048576) ? sprintf('%.2f ' . $user->lang['MB'], ($database_size / 1048576)) : (($database_size >= 1024) ? sprintf('%.2f ' . $user->lang['KB'], ($database_size / 1024)) : sprintf('%.2f ' . $user->lang['BYTES'], $database_size));
}
else
{
$database_size = $user->lang['NOT_AVAILABLE'];
}
$database_size = ($database_size !== false) ? get_formatted_filesize($database_size) : $user->lang['NOT_AVAILABLE'];
return $database_size;
}
@ -2979,6 +2972,29 @@ function tidy_database()
{
global $db;
// Here we check permission consistency
// Sometimes, it can happen permission tables having forums listed which do not exist
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE;
$result = $db->sql_query($sql);
$forum_ids = array(0);
while ($row = $db->sql_fetchrow($result))
{
$forum_ids[] = $row['forum_id'];
}
$db->sql_freeresult($result);
// Delete those rows from the acl tables not having listed the forums above
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true);
$db->sql_query($sql);
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true);
$db->sql_query($sql);
set_config('database_last_gc', time(), true);
}

View file

@ -824,7 +824,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,
$filesize = $attachment['filesize'];
$size_lang = ($filesize >= 1048576) ? $user->lang['MB'] : ( ($filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] );
$filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize);
$filesize = get_formatted_filesize($filesize, false);
$comment = bbcode_nl2br(censor_text($attachment['attach_comment']));

View file

@ -873,13 +873,13 @@ class custom_profile
}
else
{
$var = request_var($var_name, $profile_row['field_default_value']);
$var = request_var($var_name, (int) $profile_row['field_default_value']);
}
break;
case FIELD_STRING:
case FIELD_TEXT:
$var = utf8_normalize_nfc(request_var($var_name, $profile_row['field_default_value'], true));
$var = utf8_normalize_nfc(request_var($var_name, (string) $profile_row['field_default_value'], true));
break;
case FIELD_INT:
@ -889,10 +889,14 @@ class custom_profile
}
else
{
$var = request_var($var_name, $profile_row['field_default_value']);
$var = request_var($var_name, (int) $profile_row['field_default_value']);
}
break;
case FIELD_DROPDOWN:
$var = request_var($var_name, (int) $profile_row['field_default_value']);
break;
default:
$var = request_var($var_name, $profile_row['field_default_value']);
break;

View file

@ -387,7 +387,7 @@ class filespec
if ($this->upload->max_filesize && ($this->get('filesize') > $this->upload->max_filesize || $this->filesize == 0))
{
$size_lang = ($this->upload->max_filesize >= 1048576) ? $user->lang['MB'] : (($this->upload->max_filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] );
$max_filesize = ($this->upload->max_filesize >= 1048576) ? round($this->upload->max_filesize / 1048576 * 100) / 100 : (($this->upload->max_filesize >= 1024) ? round($this->upload->max_filesize / 1024 * 100) / 100 : $this->upload->max_filesize);
$max_filesize = get_formatted_filesize($this->upload->max_filesize, false);
$this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_FILESIZE'], $max_filesize, $size_lang);
@ -778,7 +778,7 @@ class fileupload
case 2:
$size_lang = ($this->max_filesize >= 1048576) ? $user->lang['MB'] : (($this->max_filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] );
$max_filesize = ($this->max_filesize >= 1048576) ? round($this->max_filesize / 1048576 * 100) / 100 : (($this->max_filesize >= 1024) ? round($this->max_filesize / 1024 * 100) / 100 : $this->max_filesize);
$max_filesize = get_formatted_filesize($this->max_filesize, false);
$error = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize, $size_lang);
break;
@ -814,7 +814,7 @@ class fileupload
if ($this->max_filesize && ($file->get('filesize') > $this->max_filesize || $file->get('filesize') == 0))
{
$size_lang = ($this->max_filesize >= 1048576) ? $user->lang['MB'] : (($this->max_filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] );
$max_filesize = ($this->max_filesize >= 1048576) ? round($this->max_filesize / 1048576 * 100) / 100 : (($this->max_filesize >= 1024) ? round($this->max_filesize / 1024 * 100) / 100 : $this->max_filesize);
$max_filesize = get_formatted_filesize($this->max_filesize, false);
$file->error[] = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize, $size_lang);
}

View file

@ -150,7 +150,7 @@ class ucp_attachments
'FILENAME' => $row['real_filename'],
'COMMENT' => bbcode_nl2br($row['attach_comment']),
'EXTENSION' => $row['extension'],
'SIZE' => ($row['filesize'] >= 1048576) ? ($row['filesize'] >> 20) . ' ' . $user->lang['MB'] : (($row['filesize'] >= 1024) ? ($row['filesize'] >> 10) . ' ' . $user->lang['KB'] : $row['filesize'] . ' ' . $user->lang['BYTES']),
'SIZE' => get_formatted_filesize($row['filesize']),
'DOWNLOAD_COUNT' => $row['download_count'],
'POST_TIME' => $user->format_date($row['filetime']),
'TOPIC_TITLE' => ($row['in_message']) ? $row['message_title'] : $row['topic_title'],

View file

@ -709,8 +709,8 @@ class ucp_groups
'U_SWATCH' => append_sid("{$phpbb_root_path}adm/swatch.$phpEx", 'form=ucp&amp;name=group_colour'),
'S_UCP_ACTION' => $this->u_action . "&amp;action=$action&amp;g=$group_id",
'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)))
);
'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024),
));
break;
@ -1014,6 +1014,8 @@ class ucp_groups
{
trigger_error($user->lang[$error] . $return_page);
}
trigger_error($user->lang['GROUP_USERS_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&amp;action=list&amp;g=' . $group_id . '">', '</a>'));
}
else
{
@ -1028,7 +1030,7 @@ class ucp_groups
confirm_box(false, sprintf($user->lang['GROUP_CONFIRM_ADD_USER' . ((sizeof($name_ary) == 1) ? '' : 'S')], implode(', ', $name_ary)), build_hidden_fields($s_hidden_fields));
}
trigger_error($user->lang['GROUP_USERS_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&amp;action=list&amp;g=' . $group_id . '">', '</a>'));
trigger_error($user->lang['NO_USERS_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&amp;action=list&amp;g=' . $group_id . '">', '</a>'));
break;

View file

@ -594,8 +594,8 @@ class ucp_profile
'S_FORM_ENCTYPE' => ($can_upload) ? ' enctype="multipart/form-data"' : '',
'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)),)
);
'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024),
));
if ($display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local'])
{

View file

@ -8,7 +8,7 @@
*
*/
$updates_to_version = '3.0.0';
$updates_to_version = '3.1.0';
// Return if we "just include it" to find out for which version the database update is responsuble for
if (defined('IN_PHPBB') && defined('IN_INSTALL'))

View file

@ -1211,7 +1211,7 @@ class install_convert extends module
$template->assign_block_vars('checks', array(
'TITLE' => "skip_rows = $skip_rows",
'RESULT' => $rows . ((defined('DEBUG_EXTRA') && function_exists('memory_get_usage')) ? ceil(memory_get_usage()/1024) . ' KB' : ''),
'RESULT' => $rows . ((defined('DEBUG_EXTRA') && function_exists('memory_get_usage')) ? ceil(memory_get_usage()/1024) . ' ' . $user->lang['KIB'] : ''),
));
$mtime = explode(' ', microtime());
@ -1478,7 +1478,7 @@ class install_convert extends module
sync('topic', 'range', 'topic_id BETWEEN ' . $sync_batch . ' AND ' . $end, true, true);
$template->assign_block_vars('checks', array(
'TITLE' => sprintf($user->lang['SYNC_TOPIC_ID'], $sync_batch, ($sync_batch + $batch_size)) . ((defined('DEBUG_EXTRA') && function_exists('memory_get_usage')) ? ' [' . ceil(memory_get_usage()/1024) . ' KB]' : ''),
'TITLE' => sprintf($user->lang['SYNC_TOPIC_ID'], $sync_batch, ($sync_batch + $batch_size)) . ((defined('DEBUG_EXTRA') && function_exists('memory_get_usage')) ? ' [' . ceil(memory_get_usage()/1024) . ' ' . $user->lang['KIB'] . ']' : ''),
'RESULT' => $user->lang['DONE'],
));

View file

@ -107,6 +107,7 @@ $lang = array_merge($lang, array(
'NO_GROUPS_CREATED' => 'No groups created yet.',
'NO_PERMISSIONS' => 'Do not copy permissions',
'NO_USERS' => 'You havent entered any users.',
'NO_USERS_ADDED' => 'No users were added to the group.',
'SPECIAL_GROUPS' => 'Pre-defined groups',
'SPECIAL_GROUPS_EXPLAIN' => 'Pre-defined groups are special groups, they cannot be deleted or directly modified. However you can still add users and alter basic settings.',

View file

@ -44,10 +44,10 @@ $lang = array_merge($lang, array(
'CANNOT_BAN_FOUNDER' => 'You are not allowed to ban founder accounts.',
'CANNOT_BAN_YOURSELF' => 'You are not allowed to ban yourself.',
'CANNOT_DEACTIVATE_BOT' => 'You are not allowed to deactivate bot accounts. Please deactivate the bot instead.',
'CANNOT_DEACTIVATE_BOT' => 'You are not allowed to deactivate bot accounts. Please deactivate the bot within the bots page instead.',
'CANNOT_DEACTIVATE_FOUNDER' => 'You are not allowed to deactivate founder accounts.',
'CANNOT_DEACTIVATE_YOURSELF' => 'You are not allowed to deactivate your own account.',
'CANNOT_FORCE_REACT_BOT' => 'You are not allowed to force reactivation on bot accounts. Please deactivate the bot instead.',
'CANNOT_FORCE_REACT_BOT' => 'You are not allowed to force reactivation on bot accounts. Please deactivate the bot within the bots page instead.',
'CANNOT_FORCE_REACT_FOUNDER' => 'You are not allowed to force reactivation on founder accounts.',
'CANNOT_FORCE_REACT_YOURSELF' => 'You are not allowed to force reactivation of your own account.',
'CANNOT_REMOVE_ANONYMOUS' => 'You are not able to remove the guest user account.',

View file

@ -278,6 +278,7 @@ $lang = array_merge($lang, array(
'JUMP_TO_PAGE' => 'Click to jump to page…',
'KB' => 'KB',
'KIB' => 'KiB',
'LAST_POST' => 'Last post',
'LAST_UPDATED' => 'Last updated',
@ -311,6 +312,7 @@ $lang = array_merge($lang, array(
'MARK_ALL' => 'Mark all',
'MARK_FORUMS_READ' => 'Mark forums read',
'MB' => 'MB',
'MIB' => 'MiB',
'MCP' => 'Moderator Control Panel',
'MEMBERLIST' => 'Members',
'MEMBERLIST_EXPLAIN' => 'View complete list of members',

View file

@ -84,7 +84,7 @@ $lang = array_merge($lang, array(
'IM_MSNM_CONNECT' => 'MSNM is not connected.\nYou have to connect to MSNM to continue.',
'IM_NAME' => 'Your Name',
'IM_NO_DATA' => 'There is no suitable contact information for this user.',
'IM_NO_JABBER' => 'Sorry, direct messaging of Jabber users is not supported on this server. You will need a Jabber client installed on your system to contact the recipient above.',
'IM_NO_JABBER' => 'Sorry, direct messaging of Jabber users is not supported on this board. You will need a Jabber client installed on your system to contact the recipient above.',
'IM_RECIPIENT' => 'Recipient',
'IM_SEND' => 'Send message',
'IM_SEND_MESSAGE' => 'Send message',

View file

@ -88,7 +88,7 @@ $lang = array_merge($lang, array(
'ATTACHMENTS_DELETED' => 'Attachments successfully deleted.',
'ATTACHMENT_DELETED' => 'Attachment successfully deleted.',
'AVATAR_CATEGORY' => 'Category',
'AVATAR_EXPLAIN' => 'Maximum dimensions; width: %1$d pixels, height: %2$d pixels, file size: %3$dkB.',
'AVATAR_EXPLAIN' => 'Maximum dimensions; width: %1$d pixels, height: %2$d pixels, file size: %3$.2lf KiB.',
'AVATAR_FEATURES_DISABLED' => 'The avatar functionality is currently disabled.',
'AVATAR_GALLERY' => 'Local gallery',
'AVATAR_GENERAL_UPLOAD_ERROR' => 'Could not upload avatar to %s.',

View file

@ -66,7 +66,7 @@ onload_functions.push('subPanels()');
<dl>
<dt><label for="subject">{L_SPLIT_SUBJECT}:</label></dt>
<dd><input type="text" name="subject" id="subject" size="45" maxlength="64" tabindex="2" value="{SPLIT_SUBJECT}" title="Type the post subject" class="inputbox" /></dd>
<dd><input type="text" name="subject" id="subject" size="45" maxlength="64" tabindex="2" value="{SPLIT_SUBJECT}" title="{L_SPLIT_SUBJECT}" class="inputbox" /></dd>
</dl>
<dl>
<dt><label>{L_SPLIT_FORUM}:</label></dt>