aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/acp
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/acp')
-rw-r--r--phpBB/includes/acp/acp_attachments.php14
-rw-r--r--phpBB/includes/acp/acp_bbcodes.php4
-rw-r--r--phpBB/includes/acp/acp_main.php9
-rw-r--r--phpBB/includes/acp/acp_permissions.php103
-rw-r--r--phpBB/includes/acp/acp_styles.php2
-rw-r--r--phpBB/includes/acp/acp_users.php2
-rw-r--r--phpBB/includes/acp/auth.php46
7 files changed, 79 insertions, 101 deletions
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php
index 03e9f52e0e..120c6a789f 100644
--- a/phpBB/includes/acp/acp_attachments.php
+++ b/phpBB/includes/acp/acp_attachments.php
@@ -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>';
}
diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php
index 21370036ee..33e8fe7ec1 100644
--- a/phpBB/includes/acp/acp_bbcodes.php
+++ b/phpBB/includes/acp/acp_bbcodes.php
@@ -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-_]+)',
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php
index 57bb52f27b..bf6e8a39b5 100644
--- a/phpBB/includes/acp/acp_main.php
+++ b/phpBB/includes/acp/acp_main.php
@@ -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
{
diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php
index 1b2b19d4ab..a9e64b74ae 100644
--- a/phpBB/includes/acp/acp_permissions.php
+++ b/phpBB/includes/acp/acp_permissions.php
@@ -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,65 +1117,68 @@ 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'
- ),
-
- '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_forum_id
- AND u.user_id = a.user_id",
- 'ORDER_BY' => 'u.username_clean, u.user_regdate ASC'
- ));
+ // 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();
+
+ $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);
- $s_defined_user_options = '';
- $defined_user_ids = array();
while ($row = $db->sql_fetchrow($result))
{
- $s_defined_user_options .= '<option value="' . $row['user_id'] . '">' . $row['username'] . '</option>';
- $defined_user_ids[] = $row['user_id'];
+ $option_ids[] = (int) $row['auth_option_id'];
}
$db->sql_freeresult($result);
- $sql = $db->sql_build_query('SELECT_DISTINCT', array(
- 'SELECT' => 'g.group_type, g.group_name, g.group_id',
+ 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);
- 'FROM' => array(
- GROUPS_TABLE => 'g',
- ACL_OPTIONS_TABLE => 'o',
- ACL_GROUPS_TABLE => 'a'
- ),
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $role_ids[] = (int) $row['role_id'];
+ }
+ $db->sql_freeresult($result);
+ }
- 'LEFT_JOIN' => array(
- array(
- 'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'),
- 'ON' => 'a.auth_role_id = r.role_id'
- )
- ),
+ 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);
+ }
- 'WHERE' => "(a.auth_option_id = o.auth_option_id OR r.auth_option_id = o.auth_option_id)
- $sql_permission_option
+ // 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 g.group_id = a.group_id",
+ $sql_where
+ ORDER BY u.username_clean, u.user_regdate ASC";
+ $result = $db->sql_query($sql);
- 'ORDER_BY' => 'g.group_type DESC, g.group_name ASC'
- ));
+ $s_defined_user_options = '';
+ $defined_user_ids = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $s_defined_user_options .= '<option value="' . $row['user_id'] . '">' . $row['username'] . '</option>';
+ $defined_user_ids[] = $row['user_id'];
+ }
+ $db->sql_freeresult($result);
+
+ $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
+ $sql_where
+ ORDER BY g.group_type DESC, g.group_name ASC";
$result = $db->sql_query($sql);
$s_defined_group_options = '';
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index 74812efd84..2f2649575b 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -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']))
);
}
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index 61fd5ea752..3ad8c88fb9 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -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'],
diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php
index c64f27cee5..5c81092a65 100644
--- a/phpBB/includes/acp/auth.php
+++ b/phpBB/includes/acp/auth.php
@@ -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);