diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php
index e69e83d041..358e5a4bf2 100644
--- a/phpBB/adm/index.php
+++ b/phpBB/adm/index.php
@@ -45,8 +45,8 @@ define('IN_ADMIN', true);
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
// Some oft used variables
-$safe_mode = (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') ? true : false;
-$file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
+$safe_mode = (@ini_get('safe_mode') == '1' || @strtolower(ini_get('safe_mode')) === 'on') ? true : false;
+$file_uploads = (@ini_get('file_uploads') == '1' || strtolower(@ini_get('file_uploads')) === 'on') ? true : false;
$module_id = request_var('i', '');
$mode = request_var('mode', '');
@@ -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;
}
@@ -367,33 +367,64 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
}
/**
-* Going through a config array and validate values, writing errors to $error.
+* Going through a config array and validate values, writing errors to $error. The validation method accepts parameters separated by ':' for string and int.
+* The first parameter defines the type to be used, the second the lower bound and the third the upper bound. Only the type is required.
*/
function validate_config_vars($config_vars, &$cfg_array, &$error)
{
global $phpbb_root_path, $user;
-
+ $type = 0;
+ $min = 1;
+ $max = 2;
+
foreach ($config_vars as $config_name => $config_definition)
{
if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
{
continue;
}
-
+
if (!isset($config_definition['validate']))
{
continue;
}
+
+ $validator = explode(':', $config_definition['validate']);
- // Validate a bit. ;) String is already checked through request_var(), therefore we do not check this again
- switch ($config_definition['validate'])
+ // Validate a bit. ;) (0 = type, 1 = min, 2= max)
+ switch ($validator[$type])
{
+ case 'string':
+ $length = strlen($cfg_array[$config_name]);
+
+ // the column is a VARCHAR
+ $validator[$max] = (isset($validator[$max])) ? min(255, $validator[$max]) : 255;
+
+ if (isset($validator[$min]) && $length < $validator[$min])
+ {
+ $error[] = sprintf($user->lang['SETTING_TOO_SHORT'], $user->lang[$config_definition['lang']], $validator[$min]);
+ }
+ else if (isset($validator[$max]) && $length > $validator[2])
+ {
+ $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$config_definition['lang']], $validator[$max]);
+ }
+ break;
+
case 'bool':
$cfg_array[$config_name] = ($cfg_array[$config_name]) ? 1 : 0;
break;
case 'int':
$cfg_array[$config_name] = (int) $cfg_array[$config_name];
+
+ if (isset($validator[$min]) && $cfg_array[$config_name] < $validator[$min])
+ {
+ $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], $validator[$min]);
+ }
+ else if (isset($validator[$max]) && $cfg_array[$config_name] > $validator[$max])
+ {
+ $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$config_definition['lang']], $validator[$max]);
+ }
break;
// Absolute path
@@ -508,4 +539,62 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
return;
}
+/**
+* Checks whatever or not a variable is OK for use in the Database
+* param mixed $value_ary An array of the form array(array('lang' => ..., 'value' => ..., 'column_type' =>))'
+* param mixed $error The error array
+*/
+function validate_range($value_ary, &$error)
+{
+ global $user;
+
+ $column_types = array(
+ 'BOOL' => array('php_type' => 'int', 'min' => 0, 'max' => 1),
+ 'USINT' => array('php_type' => 'int', 'min' => 0, 'max' => 65535),
+ 'UINT' => array('php_type' => 'int', 'min' => 0, 'max' => (int) 0x7fffffff),
+ 'INT' => array('php_type' => 'int', 'min' => (int) 0x80000000, 'max' => (int) 0x7fffffff),
+ 'TINT' => array('php_type' => 'int', 'min' => -128, 'max' => 127),
+
+ 'VCHAR' => array('php_type' => 'string', 'min' => 0, 'max' => 255),
+ );
+ foreach ($value_ary as $value)
+ {
+ $column = explode(':', $value['column_type']);
+ $max = $min = 0;
+ $type = 0;
+ if (!isset($column_types[$column[0]]))
+ {
+ continue;
+ }
+ else
+ {
+ $type = $column_types[$column[0]];
+ }
+
+ switch ($type['php_type'])
+ {
+ case 'string' :
+ $max = (isset($column[1])) ? min($column[1],$type['max']) : $type['max'];
+ if (strlen($value['value']) > $max)
+ {
+ $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$value['lang']], $max);
+ }
+ break;
+
+ case 'int':
+ $min = (isset($column[1])) ? max($column[1],$type['min']) : $type['min'];
+ $max = (isset($column[2])) ? min($column[2],$type['max']) : $type['max'];
+ if ($value['value'] < $min)
+ {
+ $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$value['lang']], $min);
+ }
+ else if ($value['value'] > $max)
+ {
+ $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$value['lang']], $max);
+ }
+ break;
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html
index a002ad19ac..9573c34248 100644
--- a/phpBB/adm/style/acp_attachments.html
+++ b/phpBB/adm/style/acp_attachments.html
@@ -122,11 +122,11 @@
{
if (newimage == 'no_image')
{
- document.image_upload_icon.src = "{PHPBB_ROOT_PATH}images/spacer.gif";
+ document.getElementById('image_upload_icon').src = "{PHPBB_ROOT_PATH}images/spacer.gif";
}
else
{
- document.image_upload_icon.src = "{PHPBB_ROOT_PATH}{IMG_PATH}/" + newimage;
+ document.getElementById('image_upload_icon').src = "{PHPBB_ROOT_PATH}{IMG_PATH}/" + newimage;
}
}
@@ -192,7 +192,7 @@
selected="selected">{L_NO_IMAGE} {S_FILENAME_LIST}
- src="{PHPBB_ROOT_PATH}images/spacer.gif"src="{UPLOAD_ICON_SRC}" name="image_upload_icon" alt="" title="" />
+ src="{PHPBB_ROOT_PATH}images/spacer.gif"src="{UPLOAD_ICON_SRC}" id="image_upload_icon" alt="" title="" />
{L_MAX_EXTGROUP_FILESIZE}:
diff --git a/phpBB/adm/style/acp_bbcodes.html b/phpBB/adm/style/acp_bbcodes.html
index a0b0016a11..c81c198fd5 100644
--- a/phpBB/adm/style/acp_bbcodes.html
+++ b/phpBB/adm/style/acp_bbcodes.html
@@ -103,6 +103,10 @@
{bbcodes.BBCODE_TAG}
{ICON_EDIT} {ICON_DELETE}
+
+
+ {L_ACP_NO_ITEMS}
+
diff --git a/phpBB/adm/style/acp_database.html b/phpBB/adm/style/acp_database.html
index 8165efe9a2..ebc76c36a3 100644
--- a/phpBB/adm/style/acp_database.html
+++ b/phpBB/adm/style/acp_database.html
@@ -7,8 +7,9 @@
{L_ACP_RESTORE_EXPLAIN}
+
+
+
+
{L_ACP_BACKUP}
@@ -77,7 +81,7 @@
{tables.TABLE}
- {L_SELECT_ALL} :: {L_DESELECT_ALL}
+ {L_SELECT_ALL} :: {L_DESELECT_ALL}
diff --git a/phpBB/adm/style/acp_forums.html b/phpBB/adm/style/acp_forums.html
index 560bc195bc..e4662d9280 100644
--- a/phpBB/adm/style/acp_forums.html
+++ b/phpBB/adm/style/acp_forums.html
@@ -202,6 +202,11 @@
{L_FORUM_STATUS}:
{S_STATUS_OPTIONS}
+
+ {L_LIST_SUBFORUMS}: {L_LIST_SUBFORUMS_EXPLAIN}
+ id="display_subforum_list" checked="checked" /> {L_YES}
+ id="display_subforum_list" checked="checked" /> {L_NO}
+
{L_LIST_INDEX}: {L_LIST_INDEX_EXPLAIN}
id="display_on_index" checked="checked" /> {L_YES}
@@ -445,7 +450,7 @@
{ICON_MOVE_UP_DISABLED}
{ICON_MOVE_DOWN}
-
+
{ICON_MOVE_UP}
{ICON_MOVE_DOWN}
diff --git a/phpBB/adm/style/acp_icons.html b/phpBB/adm/style/acp_icons.html
index 8bb8257318..86500ae047 100644
--- a/phpBB/adm/style/acp_icons.html
+++ b/phpBB/adm/style/acp_icons.html
@@ -43,19 +43,19 @@
function toggle_select(icon, display, select)
{
- var disp = document.getElementById('order_disp[' + icon + ']');
- var nodisp = document.getElementById('order_no_disp[' + icon + ']');
+ var disp = document.getElementById('order_disp_' + select);
+ var nodisp = document.getElementById('order_no_disp_' + select);
disp.disabled = !display;
nodisp.disabled = display;
if (display)
{
- document.getElementById(select).selectedIndex = 0;
+ document.getElementById('order_' + select).selectedIndex = 0;
nodisp.className = 'disabled-options';
disp.className = '';
}
else
{
- document.getElementById(select).selectedIndex = {S_ORDER_LIST_DISPLAY_COUNT};
+ document.getElementById('order_' + select).selectedIndex = {S_ORDER_LIST_DISPLAY_COUNT};
disp.className = 'disabled-options';
nodisp.className = '';
}
@@ -111,15 +111,15 @@
-
+
-
- disabled="disabled" class="disabled-options" >{S_ORDER_LIST_DISPLAY}
- disabled="disabled" class="disabled-options" >{S_ORDER_LIST_UNDISPLAY}
+
+ disabled="disabled" class="disabled-options" >{S_ORDER_LIST_DISPLAY}
+ disabled="disabled" class="disabled-options" >{S_ORDER_LIST_UNDISPLAY}
@@ -248,6 +248,10 @@
{ICON_EDIT} {ICON_DELETE}
+
+
+ {L_ACP_NO_ITEMS}
+
diff --git a/phpBB/adm/style/acp_language.html b/phpBB/adm/style/acp_language.html
index 815ebb024a..95ac1d5852 100644
--- a/phpBB/adm/style/acp_language.html
+++ b/phpBB/adm/style/acp_language.html
@@ -121,9 +121,11 @@
diff --git a/phpBB/adm/style/acp_permission_roles.html b/phpBB/adm/style/acp_permission_roles.html
index 725c7a5ec1..220e7dafbe 100644
--- a/phpBB/adm/style/acp_permission_roles.html
+++ b/phpBB/adm/style/acp_permission_roles.html
@@ -28,11 +28,11 @@
{L_EXPLAIN}
-
{L_COPYRIGHT}:
- {COPYRIGHT}
+ {COPYRIGHT}
diff --git a/phpBB/adm/style/acp_words.html b/phpBB/adm/style/acp_words.html
index 9bd0bf11a0..3fa4cfc91c 100644
--- a/phpBB/adm/style/acp_words.html
+++ b/phpBB/adm/style/acp_words.html
@@ -62,6 +62,10 @@
{words.REPLACEMENT}
{ICON_EDIT} {ICON_DELETE}
+
+
+ {L_ACP_NO_ITEMS}
+
diff --git a/phpBB/adm/style/colour_swatch.html b/phpBB/adm/style/colour_swatch.html
index f3c5a812dc..c9e89980d8 100644
--- a/phpBB/adm/style/colour_swatch.html
+++ b/phpBB/adm/style/colour_swatch.html
@@ -8,7 +8,7 @@
{L_COLOUR_SWATCH}
diff --git a/phpBB/adm/style/install_update_diff.html b/phpBB/adm/style/install_update_diff.html
index b9ac19ae5d..efbe1d045c 100644
--- a/phpBB/adm/style/install_update_diff.html
+++ b/phpBB/adm/style/install_update_diff.html
@@ -32,7 +32,7 @@ function resize_panel()
diff --git a/phpBB/common.php b/phpBB/common.php
index ebffd46228..4fca1be2b4 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -131,7 +131,7 @@ if (!defined('PHPBB_INSTALLED'))
// Redirect the user to the installer
// We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
// available as used by the redirect function
- $server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME');
+ $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
$secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
@@ -150,7 +150,11 @@ if (!defined('PHPBB_INSTALLED'))
if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
{
- $url .= ':' . $server_port;
+ // HTTP HOST can carry a port number...
+ if (strpos($server_name, ':') === false)
+ {
+ $url .= ':' . $server_port;
+ }
}
$url .= $script_path;
diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php
index 9ee9a81299..cefdf404dd 100644
--- a/phpBB/develop/create_schema_files.php
+++ b/phpBB/develop/create_schema_files.php
@@ -1072,6 +1072,7 @@ function get_schema_struct()
'forum_last_poster_name'=> array('VCHAR_UNI', ''),
'forum_last_poster_colour'=> array('VCHAR:6', ''),
'forum_flags' => array('TINT:4', 32),
+ 'display_subforum_list' => array('BOOL', 1),
'display_on_index' => array('BOOL', 1),
'enable_indexing' => array('BOOL', 1),
'enable_icons' => array('BOOL', 1),
@@ -1143,7 +1144,7 @@ function get_schema_struct()
),
'PRIMARY_KEY' => 'group_id',
'KEYS' => array(
- 'group_legend' => array('INDEX', 'group_legend'),
+ 'group_legend_name' => array('INDEX', array('group_legend', 'group_name')),
),
);
@@ -1519,6 +1520,7 @@ function get_schema_struct()
'COLUMNS' => array(
'session_id' => array('CHAR:32', ''),
'session_user_id' => array('UINT', 0),
+ 'session_forum_id' => array('UINT', 0),
'session_last_visit' => array('TIMESTAMP', 0),
'session_start' => array('TIMESTAMP', 0),
'session_time' => array('TIMESTAMP', 0),
@@ -1534,6 +1536,7 @@ function get_schema_struct()
'KEYS' => array(
'session_time' => array('INDEX', 'session_time'),
'session_user_id' => array('INDEX', 'session_user_id'),
+ 'session_forum_id' => array('INDEX', 'session_forum_id'),
),
);
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index c602cfdcd2..26f7a74021 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -53,6 +53,7 @@
Changelog
+ Changes since 3.0.0
Changes since RC-8
Changes since RC-7
Changes since RC-6
@@ -70,7 +71,7 @@
-
+
1. Changelog
@@ -80,6 +81,75 @@
+
1.i. Changes since 3.0.0
+
+
+ [Change] Validate birthdays (Bug #15004)
+ [Fix] Allow correct avatar caching for CGI installations. (thanks wildbill)
+ [Fix] Fix disabling of word censor, now possible again
+ [Fix] Allow single quotes in db password to be stored within config.php in installer
+ [Fix] Correctly quote db password for re-display in installer (Bug #16695 / thanks to m313 for reporting too - #s17235)
+ [Fix] Correctly handle empty imageset entries (Bug #16865)
+ [Fix] Correctly check empty subjects/messages (Bug #17915)
+ [Change] Do not check usernames against word censor list. Disallowed usernames is already checked and word censor belong to posts. (Bug #17745)
+ [Fix] Additionally include non-postable forums for moderators forums shown within the teams list. (Bug #17265)
+ [Change] Sped up viewforum considerably (also goes towards mcp_forum)
+ [Fix] Do not split topic list for topics being promoted to announcements after been moved to another forum (Bug #18635)
+ [Fix] Allow editing usernames within database_update on username cleanup (Bug #18415)
+ [Fix] Fixing wrong sync() calls if moving all posts by a member in ACP (Bug #18385)
+ [Fix] Check entered imagemagick path for trailing slash (Bug #18205)
+ [Fix] Use proper title on index for new/unread posts (Bug #13101) - patch provided by Pyramide
+ [Fix] Allow calls to $user->set_cookie() define no cookie time for setting session cookies (Bug #18025)
+ [Fix] Stricter checks on smilie packs (Bug #19675)
+ [Fix] Gracefully return from cancelling pm drafts (Bug #19675)
+ [Fix] Possible login problems with IE7 if browser check is activated (Bug #20135)
+ [Fix] Fix possible database transaction errors if code returns on error and rollback happened (Bug #17025)
+ [Change] Allow numbers in permission names for modifications, as well as uppercase letters for the request_ part (Bug #20125)
+ [Fix] Use HTTP_HOST in favor of SERVER_NAME for determining server url for redirection and installation (Bug #19955)
+ [Fix] Removing s_watching_img from watch_topic_forum() function (Bug #20445)
+ [Fix] Changing order for post review if more than one post affected (Bug #15249)
+ [Fix] Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479, #20795, #21095, #21405, #21715, #21725, #21755, #21865, #15689)
+ [Fix] Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738, #19725)
+ [Fix] Tiny code fixes (Bug #20165, #20025, #19795, #14804)
+ [Fix] Prepend phpbb_root_path to ranks path for displaying ranks (Bug #19075)
+ [Fix] Allow forum notifications if topic notifications are disabled but forum notifications enabled (Bug #14765)
+ [Fix] Fixing realpath issues for provider returning the passed value instead of disabling it. This fixes issues with confirm boxes for those hosted on Network Solutions for example. (Bug #20435)
+ [Fix] Try to sort last active date on memberlist correctly at least on current page (Bug #18665)
+ [Fix] Handle generation of form tokens when maximum time is set to -1
+ [Fix] Correctly delete unapproved posts without deleting the topic (Bug #15120)
+ [Fix] Respect signature permissions in posting (Bug #16029)
+ [Fix] Users allowed to resign only from open and freely open groups (Bug #19355)
+ [Fix] Assign a last viewed date to converted topics (Bug #16565)
+ [Fix] Many minor and/or cosmetic fixes (Including, but not limited to: #21315, #18575, #18435, #21215)
+ [Feature] New option to hide the entire list of subforums on listforums
+ [Fix] Custom BBCode {EMAIL}-Token usage (Bug #21155)
+ [Fix] Do not rely on parameter returned by unlink() for verifying cache directory write permission (Bug #19565)
+ [Change] Use correct string for filesize (MiB instead of MB for example)
+ [Change] Remove left join for query used to retrieve already assigned users and groups within permission panel (Bug #20235)
+ [Fix] Correctly return sole whitespaces if used with BBCodes (Bug #19535)
+ [Fix] Quote bbcode parsing adding too much closing tags on special conditions (Bug #20735)
+ [Change] Added sanity checks to various ACP settings
+ [Change] Removed minimum form times
+ [Fix] Check topics_per_page value in acp_forums (Bug #15539)
+ [Fix] Custom profile fields with date type should be timezone independend (Bug #15003)
+ [Fix] Fixing some XHTML errors/warnings within the ACP (Bug #22875)
+ [Fix] Warnings if poll title/options exceed maximum characters per post (Bug #22865)
+ [Fix] Do not allow selecting non-authorized groups within memberlist by adjusting URL (Bug #22805 - patch provided by ToonArmy)
+ [Fix] Correctly specify "close report action" (Bug #22685)
+ [Fix] Display "empty password error" within the login box instead of issuing a general error (Bug #22525)
+ [Fix] Clean up who is online code in page_header (Bug #22715, thanks HighwayofLife)
+ [Fix] Pertain select single link on memberlist (Bug #23235 - patch provided by Schumi)
+ [Fix] Allow & and | in local part of email addresses (Bug #22995)
+ [Fix] Do not error out if php_uname function disabled / Authenticating on SMTP Server (Bug #22235 - patch by HoL)
+ [Fix] Correctly obtain to be ignored users within topic/forum notification (Bug #21795 - patch provided by dr.death)
+ [Fix] Correctly update board statistics for attaching orphaned files to existing posts (Bug #20185)
+ [Fix] Do not detect the board URL as a link twice in posts (Bug #19215)
+ [Fix] Set correct error reporting in style.php to avoid blank pages after CSS changes (Bug #23885)
+ [Fix] If pruning users based on last activity, do not include users never logged in before (Bug #18105)
+ [Sec] Only allow searching by email address in memberlist for users having the a_user permission (reported by evil<3)
+ [Sec] Limit private message attachments to be viewable only by the recipient(s)/sender (Report #s23535) - reported by AlleyKat
+
+
1.i. Changes since 3.0.RC8
diff --git a/phpBB/docs/INSTALL.html b/phpBB/docs/INSTALL.html
index 4f9e4ded70..40ae50047b 100644
--- a/phpBB/docs/INSTALL.html
+++ b/phpBB/docs/INSTALL.html
@@ -281,9 +281,9 @@
4.iii. Patch file
- The patch file package is for those wanting to update through the patch application, and being compfortable with it.
+ The patch file package is for those wanting to update through the patch application, and being comfortable with it.
- 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 patch application. If you do not have access to such an application but still want to use this update approach, we strongly recommend the Automatic update package explained below. It is also the preferred update method.
+ 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 patch application. If you do not have access to such an application but still want to use this update approach, we strongly recommend the Automatic update package explained below. It is also the preferred update method.
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: patch -cl -d [PHPBB DIRECTORY] -p1 < [PATCH NAME] (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.
@@ -369,7 +369,7 @@
Password conversion 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.
- Path to your former board The converter expects the relative path to your old board's files. So, -for instance - if the new board is located at http://www.yourdomain.com/forum
and the phpBB3 is located at http://www.yourdomain.com/phpBB3
, then the correct value would be ../forum
. Note that the webserver user must be able to access the source installation's files.
+ Path to your former board The converter expects the relative path to your old board's files. So, - for instance - if the old board is located at http://www.yourdomain.com/forum
and the phpBB3 installation is located at http://www.yourdomain.com/phpBB3
, then the correct value would be ../forum
. Note that the webserver user must be able to access the source installation's files.
Missing images 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.
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html
index 124ac74bb9..837ae55227 100644
--- a/phpBB/docs/coding-guidelines.html
+++ b/phpBB/docs/coding-guidelines.html
@@ -110,7 +110,7 @@
If entered with tabs (replace the {TAB}) both equal signs need to be on the same column.
Linefeeds:
- 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.
+ 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.
1.ii. File Header
@@ -1059,7 +1059,7 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&
-A bit later loops will be explained further. To not irretate you we will explain conditionals as well as other statements first.
+A bit later loops will be explained further. To not irritate you we will explain conditionals as well as other statements first.
Including files
Something that existed in 2.0.x which no longer exists in 3.0.x is the ability to assign a template to a variable. This was used (for example) to output the jumpbox. Instead (perhaps better, perhaps not but certainly more flexible) we now have INCLUDE. This takes the simple form:
diff --git a/phpBB/docs/hook_system.html b/phpBB/docs/hook_system.html
index b7fd702987..565e0096fc 100644
--- a/phpBB/docs/hook_system.html
+++ b/phpBB/docs/hook_system.html
@@ -14,7 +14,7 @@
phpBB3 • Hook System
diff --git a/phpBB/download/file.php b/phpBB/download/file.php
index c3ba3820f9..9940bf9aa5 100644
--- a/phpBB/download/file.php
+++ b/phpBB/download/file.php
@@ -32,7 +32,7 @@ if (isset($_GET['avatar']))
exit;
}
unset($dbpasswd);
-
+
// worst-case default
$browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : 'msie 6.0';
@@ -44,11 +44,11 @@ if (isset($_GET['avatar']))
$avatar_group = true;
$filename = substr($filename, 1);
}
-
+
// '==' is not a bug - . as the first char is as bad as no dot at all
if (strpos($filename, '.') == false)
{
- header('HTTP/1.0 403 forbidden');
+ header('HTTP/1.0 403 Forbidden');
if (!empty($cache))
{
$cache->unload();
@@ -56,33 +56,40 @@ if (isset($_GET['avatar']))
$db->sql_close();
exit;
}
-
+
$ext = substr(strrchr($filename, '.'), 1);
$stamp = (int) substr(stristr($filename, '_'), 1);
$filename = (int) $filename;
-
+
// let's see if we have to send the file at all
$last_load = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime(trim($_SERVER['HTTP_IF_MODIFIED_SINCE'])) : false;
if (strpos(strtolower($browser), 'msie 6.0') === false)
{
if ($last_load !== false && $last_load <= $stamp)
{
- header('Not Modified', true, 304);
+ if (@php_sapi_name() === 'CGI')
+ {
+ header('Status: 304 Not Modified', true, 304);
+ }
+ else
+ {
+ header('HTTP/1.0 304 Not Modified', true, 304);
+ }
// seems that we need those too ... browsers
header('Pragma: public');
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 31536000));
exit();
- }
+ }
else
{
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stamp) . ' GMT');
}
}
-
+
if (!in_array($ext, array('png', 'gif', 'jpg', 'jpeg')))
{
// no way such an avatar could exist. They are not following the rules, stop the show.
- header("HTTP/1.0 403 forbidden");
+ header("HTTP/1.0 403 Forbidden");
if (!empty($cache))
{
$cache->unload();
@@ -90,11 +97,11 @@ if (isset($_GET['avatar']))
$db->sql_close();
exit;
}
-
+
if (!$filename)
{
// no way such an avatar could exist. They are not following the rules, stop the show.
- header("HTTP/1.0 403 forbidden");
+ header("HTTP/1.0 403 Forbidden");
if (!empty($cache))
{
$cache->unload();
@@ -201,8 +208,32 @@ else
$row['forum_id'] = false;
if (!$auth->acl_get('u_pm_download'))
{
+ header('HTTP/1.0 403 Forbidden');
trigger_error('SORRY_AUTH_VIEW_ATTACH');
}
+
+ // Check if the attachment is within the users scope...
+ $sql = 'SELECT user_id, author_id
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE msg_id = ' . $attachment['post_msg_id'];
+ $result = $db->sql_query($sql);
+
+ $allowed = false;
+ while ($user_row = $db->sql_fetchrow($result))
+ {
+ if ($user->data['user_id'] == $user_row['user_id'] || $user->data['user_id'] == $user_row['author_id'])
+ {
+ $allowed = true;
+ break;
+ }
+ }
+ $db->sql_freeresult($result);
+
+ if (!$allowed)
+ {
+ header('HTTP/1.0 403 Forbidden');
+ trigger_error('ERROR_NO_ATTACHMENT');
+ }
}
// disallowed?
@@ -215,6 +246,7 @@ else
if (!download_allowed())
{
+ header('HTTP/1.0 403 Forbidden');
trigger_error($user->lang['LINKAGE_FORBIDDEN']);
}
@@ -273,7 +305,7 @@ else
{
trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']);
}
-
+
redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']);
exit;
}
@@ -460,7 +492,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
{
header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename'])));
}
-
+
if ($size)
{
header("Content-Length: $size");
@@ -549,9 +581,9 @@ function download_allowed()
}
}
}
-
+
// Check for own server...
- $server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME');
+ $server_name = $user->host;
// Forcing server vars is the only way to specify/override the protocol
if ($config['force_server_vars'] || !$server_name)
@@ -563,7 +595,7 @@ function download_allowed()
{
$allowed = true;
}
-
+
// Get IP's and Hostnames
if (!$allowed)
{
@@ -613,7 +645,7 @@ function download_allowed()
}
$db->sql_freeresult($result);
}
-
+
return $allowed;
}
diff --git a/phpBB/images/smilies/icon_arrow.gif b/phpBB/images/smilies/icon_arrow.gif
index 2880055cc0..c0f9117b96 100644
Binary files a/phpBB/images/smilies/icon_arrow.gif and b/phpBB/images/smilies/icon_arrow.gif differ
diff --git a/phpBB/images/smilies/icon_cool.gif b/phpBB/images/smilies/icon_cool.gif
index cead0306c0..6dd150375d 100644
Binary files a/phpBB/images/smilies/icon_cool.gif and b/phpBB/images/smilies/icon_cool.gif differ
diff --git a/phpBB/images/smilies/icon_cry.gif b/phpBB/images/smilies/icon_cry.gif
index 7d54b1f994..21a5a3c113 100644
Binary files a/phpBB/images/smilies/icon_cry.gif and b/phpBB/images/smilies/icon_cry.gif differ
diff --git a/phpBB/images/smilies/icon_e_biggrin.gif b/phpBB/images/smilies/icon_e_biggrin.gif
index 0d5cd010d7..08be8479b2 100644
Binary files a/phpBB/images/smilies/icon_e_biggrin.gif and b/phpBB/images/smilies/icon_e_biggrin.gif differ
diff --git a/phpBB/images/smilies/icon_e_confused.gif b/phpBB/images/smilies/icon_e_confused.gif
index ed83270804..be5b583c0c 100644
Binary files a/phpBB/images/smilies/icon_e_confused.gif and b/phpBB/images/smilies/icon_e_confused.gif differ
diff --git a/phpBB/images/smilies/icon_e_geek.gif b/phpBB/images/smilies/icon_e_geek.gif
index c1947cc03b..535bc9f723 100644
Binary files a/phpBB/images/smilies/icon_e_geek.gif and b/phpBB/images/smilies/icon_e_geek.gif differ
diff --git a/phpBB/images/smilies/icon_e_sad.gif b/phpBB/images/smilies/icon_e_sad.gif
index 57f00ba601..7cd3016a96 100644
Binary files a/phpBB/images/smilies/icon_e_sad.gif and b/phpBB/images/smilies/icon_e_sad.gif differ
diff --git a/phpBB/images/smilies/icon_e_smile.gif b/phpBB/images/smilies/icon_e_smile.gif
index 6bb8d04b72..d1ec74c8e0 100644
Binary files a/phpBB/images/smilies/icon_e_smile.gif and b/phpBB/images/smilies/icon_e_smile.gif differ
diff --git a/phpBB/images/smilies/icon_e_surprised.gif b/phpBB/images/smilies/icon_e_surprised.gif
index a53613a4e9..1be6041e3a 100644
Binary files a/phpBB/images/smilies/icon_e_surprised.gif and b/phpBB/images/smilies/icon_e_surprised.gif differ
diff --git a/phpBB/images/smilies/icon_e_ugeek.gif b/phpBB/images/smilies/icon_e_ugeek.gif
index 63e2a6737a..0d3c17994d 100644
Binary files a/phpBB/images/smilies/icon_e_ugeek.gif and b/phpBB/images/smilies/icon_e_ugeek.gif differ
diff --git a/phpBB/images/smilies/icon_e_wink.gif b/phpBB/images/smilies/icon_e_wink.gif
index 1957f24eac..fb1c1402d2 100644
Binary files a/phpBB/images/smilies/icon_e_wink.gif and b/phpBB/images/smilies/icon_e_wink.gif differ
diff --git a/phpBB/images/smilies/icon_eek.gif b/phpBB/images/smilies/icon_eek.gif
index 5d3978106a..cbe9b7b6ab 100644
Binary files a/phpBB/images/smilies/icon_eek.gif and b/phpBB/images/smilies/icon_eek.gif differ
diff --git a/phpBB/images/smilies/icon_evil.gif b/phpBB/images/smilies/icon_evil.gif
index ab1aa8e123..98e6535fde 100644
Binary files a/phpBB/images/smilies/icon_evil.gif and b/phpBB/images/smilies/icon_evil.gif differ
diff --git a/phpBB/images/smilies/icon_exclaim.gif b/phpBB/images/smilies/icon_exclaim.gif
index 6e50e2eecd..2b4a3df330 100644
Binary files a/phpBB/images/smilies/icon_exclaim.gif and b/phpBB/images/smilies/icon_exclaim.gif differ
diff --git a/phpBB/images/smilies/icon_idea.gif b/phpBB/images/smilies/icon_idea.gif
index a40ae0d7e8..e51d542bfe 100644
Binary files a/phpBB/images/smilies/icon_idea.gif and b/phpBB/images/smilies/icon_idea.gif differ
diff --git a/phpBB/images/smilies/icon_lol.gif b/phpBB/images/smilies/icon_lol.gif
index 374ba150fb..3042b00d6b 100644
Binary files a/phpBB/images/smilies/icon_lol.gif and b/phpBB/images/smilies/icon_lol.gif differ
diff --git a/phpBB/images/smilies/icon_mad.gif b/phpBB/images/smilies/icon_mad.gif
index 1f6c3c2fb4..994216615b 100644
Binary files a/phpBB/images/smilies/icon_mad.gif and b/phpBB/images/smilies/icon_mad.gif differ
diff --git a/phpBB/images/smilies/icon_mrgreen.gif b/phpBB/images/smilies/icon_mrgreen.gif
index b54cd0f946..dcb44bb01a 100644
Binary files a/phpBB/images/smilies/icon_mrgreen.gif and b/phpBB/images/smilies/icon_mrgreen.gif differ
diff --git a/phpBB/images/smilies/icon_neutral.gif b/phpBB/images/smilies/icon_neutral.gif
index 4f311567ed..41c3e14c48 100644
Binary files a/phpBB/images/smilies/icon_neutral.gif and b/phpBB/images/smilies/icon_neutral.gif differ
diff --git a/phpBB/images/smilies/icon_question.gif b/phpBB/images/smilies/icon_question.gif
index 9d072265bb..13936f71a6 100644
Binary files a/phpBB/images/smilies/icon_question.gif and b/phpBB/images/smilies/icon_question.gif differ
diff --git a/phpBB/images/smilies/icon_razz.gif b/phpBB/images/smilies/icon_razz.gif
index 29da2a2fcc..a262743958 100644
Binary files a/phpBB/images/smilies/icon_razz.gif and b/phpBB/images/smilies/icon_razz.gif differ
diff --git a/phpBB/images/smilies/icon_redface.gif b/phpBB/images/smilies/icon_redface.gif
index ad7628320c..d23a1396a0 100644
Binary files a/phpBB/images/smilies/icon_redface.gif and b/phpBB/images/smilies/icon_redface.gif differ
diff --git a/phpBB/images/smilies/icon_rolleyes.gif b/phpBB/images/smilies/icon_rolleyes.gif
index d7f5f2f4b1..0707821667 100644
Binary files a/phpBB/images/smilies/icon_rolleyes.gif and b/phpBB/images/smilies/icon_rolleyes.gif differ
diff --git a/phpBB/images/smilies/icon_twisted.gif b/phpBB/images/smilies/icon_twisted.gif
index 502fe247e8..a555dd0ab3 100644
Binary files a/phpBB/images/smilies/icon_twisted.gif and b/phpBB/images/smilies/icon_twisted.gif differ
diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php
index 775e8d4495..5851016f3d 100644
--- a/phpBB/includes/acm/acm_file.php
+++ b/phpBB/includes/acm/acm_file.php
@@ -312,7 +312,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]))
{
@@ -375,7 +375,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;
}
@@ -489,13 +489,15 @@ class acm
/**
* Removes/unlinks file
*/
- function remove_file($filename)
+ 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);
}
}
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php
index 4ab47ec9d6..d6f32bda53 100644
--- a/phpBB/includes/acp/acp_attachments.php
+++ b/phpBB/includes/acp/acp_attachments.php
@@ -23,7 +23,7 @@ class acp_attachments
{
var $u_action;
var $new_config;
-
+
function main($id, $mode)
{
global $db, $user, $auth, $template, $cache;
@@ -56,7 +56,7 @@ class acp_attachments
case 'ext_groups':
$l_title = 'ACP_EXTENSION_GROUPS';
break;
-
+
case 'orphan':
$l_title = 'ACP_ORPHAN_ATTACHMENTS';
break;
@@ -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)
@@ -184,7 +184,18 @@ class acp_attachments
}
// We strip eventually manual added convert program, we only want the patch
- $this->new_config['img_imagick'] = str_replace(array('convert', '.exe'), array('', ''), $this->new_config['img_imagick']);
+ if ($this->new_config['img_imagick'])
+ {
+ // Change path separator
+ $this->new_config['img_imagick'] = str_replace('\\', '/', $this->new_config['img_imagick']);
+ $this->new_config['img_imagick'] = str_replace(array('convert', '.exe'), array('', ''), $this->new_config['img_imagick']);
+
+ // Check for trailing slash
+ if (substr($this->new_config['img_imagick'], -1) !== '/')
+ {
+ $this->new_config['img_imagick'] .= '/';
+ }
+ }
$supported_types = get_supported_image_types();
@@ -201,7 +212,7 @@ class acp_attachments
// Secure Download Options - Same procedure as with banning
$allow_deny = ($this->new_config['secure_allow_deny']) ? 'ALLOWED' : 'DISALLOWED';
-
+
$sql = 'SELECT *
FROM ' . SITELIST_TABLE;
$result = $db->sql_query($sql);
@@ -271,7 +282,7 @@ class acp_attachments
'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars),
)
);
-
+
unset($display_vars['vars'][$config_key]);
}
@@ -323,7 +334,7 @@ class acp_attachments
FROM ' . EXTENSIONS_TABLE . '
WHERE ' . $db->sql_in_set('extension_id', $extension_id_list);
$result = $db->sql_query($sql);
-
+
$extension_list = '';
while ($row = $db->sql_fetchrow($result))
{
@@ -353,7 +364,7 @@ class acp_attachments
FROM ' . EXTENSIONS_TABLE . "
WHERE extension = '" . $db->sql_escape($add_extension) . "'";
$result = $db->sql_query($sql);
-
+
if ($row = $db->sql_fetchrow($result))
{
$error[] = sprintf($user->lang['EXTENSION_EXIST'], $add_extension);
@@ -489,7 +500,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'])
@@ -592,7 +603,7 @@ class acp_attachments
SET group_id = 0
WHERE group_id = $group_id";
$db->sql_query($sql);
-
+
add_log('admin', 'LOG_ATTACH_EXTGROUP_DEL', $group_name);
$cache->destroy('_extensions');
@@ -662,8 +673,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'];
@@ -889,7 +899,7 @@ class acp_attachments
$upload_list = array();
foreach ($add_files as $attach_id)
{
- if (!in_array($attach_id, array_keys($delete_files)) && !empty($post_ids[$attach_id]))
+ if (!isset($delete_files[$attach_id]) && !empty($post_ids[$attach_id]))
{
$upload_list[$attach_id] = $post_ids[$attach_id];
}
@@ -930,6 +940,7 @@ class acp_attachments
AND is_orphan = 1';
$result = $db->sql_query($sql);
+ $files_added = $space_taken = 0;
while ($row = $db->sql_fetchrow($result))
{
$post_row = $post_info[$upload_list[$row['attach_id']]];
@@ -969,9 +980,18 @@ class acp_attachments
WHERE topic_id = ' . $post_row['topic_id'];
$db->sql_query($sql);
+ $space_taken += $row['filesize'];
+ $files_added++;
+
add_log('admin', 'LOG_ATTACH_FILEUPLOAD', $post_row['post_id'], $row['real_filename']);
}
$db->sql_freeresult($result);
+
+ if ($files_added)
+ {
+ set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, true);
+ set_config('num_files', $config['num_files'] + $files_added, true);
+ }
}
}
@@ -989,11 +1009,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']),
@@ -1039,7 +1056,7 @@ class acp_attachments
ATTACHMENT_CATEGORY_FLASH => $user->lang['CAT_FLASH_FILES'],
ATTACHMENT_CATEGORY_QUICKTIME => $user->lang['CAT_QUICKTIME_FILES'],
);
-
+
if ($group_id)
{
$sql = 'SELECT cat_id
@@ -1055,7 +1072,7 @@ class acp_attachments
{
$cat_type = ATTACHMENT_CATEGORY_NONE;
}
-
+
$group_select = '';
foreach ($types as $type => $mode)
@@ -1075,7 +1092,7 @@ class acp_attachments
function group_select($select_name, $default_group = false, $key = '')
{
global $db, $user;
-
+
$group_select = '';
$sql = 'SELECT group_id, group_name
@@ -1093,7 +1110,7 @@ class acp_attachments
$row['group_id'] = 0;
$row['group_name'] = $user->lang['NOT_ASSIGNED'];
$group_name[] = $row;
-
+
for ($i = 0; $i < sizeof($group_name); $i++)
{
if ($default_group === false)
@@ -1127,14 +1144,14 @@ class acp_attachments
if (empty($magic_home))
{
$locations = array('C:/WINDOWS/', 'C:/WINNT/', 'C:/WINDOWS/SYSTEM/', 'C:/WINNT/SYSTEM/', 'C:/WINDOWS/SYSTEM32/', 'C:/WINNT/SYSTEM32/', '/usr/bin/', '/usr/sbin/', '/usr/local/bin/', '/usr/local/sbin/', '/opt/', '/usr/imagemagick/', '/usr/bin/imagemagick/');
- $path_locations = str_replace('\\', '/', (explode(($exe) ? ';' : ':', getenv('PATH'))));
+ $path_locations = str_replace('\\', '/', (explode(($exe) ? ';' : ':', getenv('PATH'))));
$locations = array_merge($path_locations, $locations);
foreach ($locations as $location)
{
// The path might not end properly, fudge it
- if (substr($location, -1, 1) !== '/')
+ if (substr($location, -1) !== '/')
{
$location .= '/';
}
@@ -1341,7 +1358,7 @@ class acp_attachments
$db->sql_query($sql);
}
}
-
+
if (!empty($ip_list_log))
{
// Update log
@@ -1399,7 +1416,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 ' ' . size_select_options($size_var) . ' ';
}
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\", '\"', ''', '(', ')'), 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_board.php b/phpBB/includes/acp/acp_board.php
index 4d467b6895..c1e94000db 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -107,9 +107,9 @@ class acp_board
'allow_avatar_local' => array('lang' => 'ALLOW_LOCAL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'allow_avatar_remote' => array('lang' => 'ALLOW_REMOTE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'allow_avatar_upload' => array('lang' => 'ALLOW_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
- 'avatar_filesize' => array('lang' => 'MAX_FILESIZE', 'validate' => 'int', 'type' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']),
- 'avatar_min' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
- 'avatar_max' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
+ 'avatar_filesize' => array('lang' => 'MAX_FILESIZE', 'validate' => 'int:0', 'type' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']),
+ 'avatar_min' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
+ 'avatar_max' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
'avatar_path' => array('lang' => 'AVATAR_STORAGE_PATH', 'validate' => 'rwpath', 'type' => 'text:20:255', 'explain' => true),
'avatar_gallery_path' => array('lang' => 'AVATAR_GALLERY_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true)
)
@@ -123,11 +123,11 @@ class acp_board
'vars' => array(
'legend1' => 'GENERAL_SETTINGS',
'allow_privmsg' => array('lang' => 'BOARD_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- 'pm_max_boxes' => array('lang' => 'BOXES_MAX', 'validate' => 'int', 'type' => 'text:4:4', 'explain' => true),
- 'pm_max_msgs' => array('lang' => 'BOXES_LIMIT', 'validate' => 'int', 'type' => 'text:4:4', 'explain' => true),
+ 'pm_max_boxes' => array('lang' => 'BOXES_MAX', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true),
+ 'pm_max_msgs' => array('lang' => 'BOXES_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true),
'full_folder_action' => array('lang' => 'FULL_FOLDER_ACTION', 'validate' => 'int', 'type' => 'select', 'method' => 'full_folder_select', 'explain' => true),
- 'pm_edit_time' => array('lang' => 'PM_EDIT_TIME', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
-
+ 'pm_edit_time' => array('lang' => 'PM_EDIT_TIME', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
+
'legend2' => 'GENERAL_OPTIONS',
'allow_mass_pm' => array('lang' => 'ALLOW_MASS_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'auth_bbcode_pm' => array('lang' => 'ALLOW_BBCODE_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
@@ -160,21 +160,21 @@ class acp_board
'legend2' => 'POSTING',
'bump_type' => false,
- 'edit_time' => array('lang' => 'EDIT_TIME', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
+ 'edit_time' => array('lang' => 'EDIT_TIME', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
'display_last_edited' => array('lang' => 'DISPLAY_LAST_EDITED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- 'flood_interval' => array('lang' => 'FLOOD_INTERVAL', 'validate' => 'int', 'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
- 'bump_interval' => array('lang' => 'BUMP_INTERVAL', 'validate' => 'int', 'type' => 'custom', 'method' => 'bump_interval', 'explain' => true),
- 'topics_per_page' => array('lang' => 'TOPICS_PER_PAGE', 'validate' => 'int', 'type' => 'text:3:4', 'explain' => false),
- 'posts_per_page' => array('lang' => 'POSTS_PER_PAGE', 'validate' => 'int', 'type' => 'text:3:4', 'explain' => false),
- 'hot_threshold' => array('lang' => 'HOT_THRESHOLD', 'validate' => 'int', 'type' => 'text:3:4', 'explain' => true),
- 'max_poll_options' => array('lang' => 'MAX_POLL_OPTIONS', 'validate' => 'int', 'type' => 'text:4:4', 'explain' => false),
- 'max_post_chars' => array('lang' => 'CHAR_LIMIT', 'validate' => 'int', 'type' => 'text:4:6', 'explain' => true),
- 'max_post_smilies' => array('lang' => 'SMILIES_LIMIT', 'validate' => 'int', 'type' => 'text:4:4', 'explain' => true),
- 'max_post_urls' => array('lang' => 'MAX_POST_URLS', 'validate' => 'int', 'type' => 'text:5:4', 'explain' => true),
- 'max_post_font_size' => array('lang' => 'MAX_POST_FONT_SIZE', 'validate' => 'int', 'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
- 'max_quote_depth' => array('lang' => 'QUOTE_DEPTH_LIMIT', 'validate' => 'int', 'type' => 'text:4:4', 'explain' => true),
- 'max_post_img_width' => array('lang' => 'MAX_POST_IMG_WIDTH', 'validate' => 'int', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
- 'max_post_img_height' => array('lang' => 'MAX_POST_IMG_HEIGHT', 'validate' => 'int', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
+ 'flood_interval' => array('lang' => 'FLOOD_INTERVAL', 'validate' => 'int:0', 'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
+ 'bump_interval' => array('lang' => 'BUMP_INTERVAL', 'validate' => 'int:0', 'type' => 'custom', 'method' => 'bump_interval', 'explain' => true),
+ 'topics_per_page' => array('lang' => 'TOPICS_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false),
+ 'posts_per_page' => array('lang' => 'POSTS_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false),
+ 'hot_threshold' => array('lang' => 'HOT_THRESHOLD', 'validate' => 'int:0', 'type' => 'text:3:4', 'explain' => true),
+ 'max_poll_options' => array('lang' => 'MAX_POLL_OPTIONS', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => false),
+ 'max_post_chars' => array('lang' => 'CHAR_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:6', 'explain' => true),
+ 'max_post_smilies' => array('lang' => 'SMILIES_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true),
+ 'max_post_urls' => array('lang' => 'MAX_POST_URLS', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true),
+ 'max_post_font_size' => array('lang' => 'MAX_POST_FONT_SIZE', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
+ 'max_quote_depth' => array('lang' => 'QUOTE_DEPTH_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true),
+ 'max_post_img_width' => array('lang' => 'MAX_POST_IMG_WIDTH', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
+ 'max_post_img_height' => array('lang' => 'MAX_POST_IMG_HEIGHT', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
)
);
break;
@@ -192,12 +192,12 @@ class acp_board
'allow_sig_links' => array('lang' => 'ALLOW_SIG_LINKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'legend2' => 'GENERAL_SETTINGS',
- 'max_sig_chars' => array('lang' => 'MAX_SIG_LENGTH', 'validate' => 'int', 'type' => 'text:5:4', 'explain' => true),
- 'max_sig_urls' => array('lang' => 'MAX_SIG_URLS', 'validate' => 'int', 'type' => 'text:5:4', 'explain' => true),
- 'max_sig_font_size' => array('lang' => 'MAX_SIG_FONT_SIZE', 'validate' => 'int', 'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
- 'max_sig_smilies' => array('lang' => 'MAX_SIG_SMILIES', 'validate' => 'int', 'type' => 'text:5:4', 'explain' => true),
- 'max_sig_img_width' => array('lang' => 'MAX_SIG_IMG_WIDTH', 'validate' => 'int', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
- 'max_sig_img_height' => array('lang' => 'MAX_SIG_IMG_HEIGHT', 'validate' => 'int', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
+ 'max_sig_chars' => array('lang' => 'MAX_SIG_LENGTH', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true),
+ 'max_sig_urls' => array('lang' => 'MAX_SIG_URLS', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true),
+ 'max_sig_font_size' => array('lang' => 'MAX_SIG_FONT_SIZE', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
+ 'max_sig_smilies' => array('lang' => 'MAX_SIG_SMILIES', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true),
+ 'max_sig_img_width' => array('lang' => 'MAX_SIG_IMG_WIDTH', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
+ 'max_sig_img_height' => array('lang' => 'MAX_SIG_IMG_HEIGHT', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
)
);
break;
@@ -207,24 +207,22 @@ class acp_board
'title' => 'ACP_REGISTER_SETTINGS',
'vars' => array(
'legend1' => 'GENERAL_SETTINGS',
- 'max_name_chars' => false,
- 'max_pass_chars' => false,
+ 'max_name_chars' => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:8:180', 'type' => false, 'method' => false, 'explain' => false,),
+ 'max_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:8:255', 'type' => false, 'method' => false, 'explain' => false,),
'require_activation' => array('lang' => 'ACC_ACTIVATION', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_acc_activation', 'explain' => true),
- 'min_name_chars' => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int', 'type' => 'custom', 'method' => 'username_length', 'explain' => true),
- 'min_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int', 'type' => 'custom', 'method' => 'password_length', 'explain' => true),
+ 'min_name_chars' => array('lang' => 'USERNAME_LENGTH', 'validate' => 'int:1', 'type' => 'custom:5:180', 'method' => 'username_length', 'explain' => true),
+ 'min_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'validate' => 'int:1', 'type' => 'custom', 'method' => 'password_length', 'explain' => true),
'allow_name_chars' => array('lang' => 'USERNAME_CHARS', 'validate' => 'string', 'type' => 'select', 'method' => 'select_username_chars', 'explain' => true),
'pass_complex' => array('lang' => 'PASSWORD_TYPE', 'validate' => 'string', 'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
- 'chg_passforce' => array('lang' => 'FORCE_PASS_CHANGE', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
+ 'chg_passforce' => array('lang' => 'FORCE_PASS_CHANGE', 'validate' => 'int:0', 'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
'legend2' => 'GENERAL_OPTIONS',
'allow_namechange' => array('lang' => 'ALLOW_NAME_CHANGE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'allow_emailreuse' => array('lang' => 'ALLOW_EMAIL_REUSE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'enable_confirm' => array('lang' => 'VISUAL_CONFIRM_REG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- 'max_login_attempts' => array('lang' => 'MAX_LOGIN_ATTEMPTS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
- 'max_reg_attempts' => array('lang' => 'REG_LIMIT', 'validate' => 'int', 'type' => 'text:4:4', 'explain' => true),
- 'min_time_reg' => array('lang' => 'MIN_TIME_REG', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
- 'min_time_terms' => array('lang' => 'MIN_TIME_TERMS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
+ 'max_login_attempts' => array('lang' => 'MAX_LOGIN_ATTEMPTS', 'validate' => 'int:0', 'type' => 'text:3:3', 'explain' => true),
+ 'max_reg_attempts' => array('lang' => 'REG_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true),
'legend3' => 'COPPA',
'coppa_enable' => array('lang' => 'ENABLE_COPPA', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
@@ -253,9 +251,9 @@ class acp_board
'vars' => array(
'legend1' => 'GENERAL_SETTINGS',
'limit_load' => array('lang' => 'LIMIT_LOAD', 'validate' => 'string', 'type' => 'text:4:4', 'explain' => true),
- 'session_length' => array('lang' => 'SESSION_LENGTH', 'validate' => 'int', 'type' => 'text:5:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
- 'active_sessions' => array('lang' => 'LIMIT_SESSIONS', 'validate' => 'int', 'type' => 'text:4:4', 'explain' => true),
- 'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'validate' => 'int', 'type' => 'text:4:3', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
+ 'session_length' => array('lang' => 'SESSION_LENGTH', 'validate' => 'int:60', 'type' => 'text:5:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
+ 'active_sessions' => array('lang' => 'LIMIT_SESSIONS', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true),
+ 'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'validate' => 'int:0', 'type' => 'text:4:3', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
'legend2' => 'GENERAL_OPTIONS',
'load_db_track' => array('lang' => 'YES_POST_MARKING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
@@ -269,7 +267,7 @@ class acp_board
'load_jumpbox' => array('lang' => 'YES_JUMPBOX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'load_user_activity' => array('lang' => 'LOAD_USER_ACTIVITY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'load_tplcompile' => array('lang' => 'RECOMPILE_STYLES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
-
+
'legend3' => 'CUSTOM_PROFILE_FIELDS',
'load_cpf_memberlist' => array('lang' => 'LOAD_CPF_MEMBERLIST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'load_cpf_viewprofile' => array('lang' => 'LOAD_CPF_VIEWPROFILE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
@@ -305,7 +303,7 @@ class acp_board
'force_server_vars' => array('lang' => 'FORCE_SERVER_VARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'server_protocol' => array('lang' => 'SERVER_PROTOCOL', 'validate' => 'string', 'type' => 'text:10:10', 'explain' => true),
'server_name' => array('lang' => 'SERVER_NAME', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true),
- 'server_port' => array('lang' => 'SERVER_PORT', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true),
+ 'server_port' => array('lang' => 'SERVER_PORT', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true),
'script_path' => array('lang' => 'SCRIPT_PATH', 'validate' => 'script_path', 'type' => 'text::255', 'explain' => true),
)
);
@@ -317,18 +315,17 @@ class acp_board
'vars' => array(
'legend1' => 'ACP_SECURITY_SETTINGS',
'allow_autologin' => array('lang' => 'ALLOW_AUTOLOGIN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- 'max_autologin_time' => array('lang' => 'AUTOLOGIN_LENGTH', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
+ 'max_autologin_time' => array('lang' => 'AUTOLOGIN_LENGTH', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
'ip_check' => array('lang' => 'IP_VALID', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_ip_check', 'explain' => true),
'browser_check' => array('lang' => 'BROWSER_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'forwarded_for_check' => array('lang' => 'FORWARDED_FOR_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'check_dnsbl' => array('lang' => 'CHECK_DNSBL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'email_check_mx' => array('lang' => 'EMAIL_CHECK_MX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'pass_complex' => array('lang' => 'PASSWORD_TYPE', 'validate' => 'string', 'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
- 'chg_passforce' => array('lang' => 'FORCE_PASS_CHANGE', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
- 'max_login_attempts' => array('lang' => 'MAX_LOGIN_ATTEMPTS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
+ 'chg_passforce' => array('lang' => 'FORCE_PASS_CHANGE', 'validate' => 'int:0', 'type' => 'text:3:3', 'explain' => true, 'append' => ' ' . $user->lang['DAYS']),
+ 'max_login_attempts' => array('lang' => 'MAX_LOGIN_ATTEMPTS', 'validate' => 'int:0', 'type' => 'text:3:3', 'explain' => true),
'tpl_allow_php' => array('lang' => 'TPL_ALLOW_PHP', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- 'form_token_lifetime' => array('lang' => 'FORM_TIME_MAX', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
- 'form_token_mintime' => array('lang' => 'FORM_TIME_MIN', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
+ 'form_token_lifetime' => array('lang' => 'FORM_TIME_MAX', 'validate' => 'int:-1', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
'form_token_sid_guests' => array('lang' => 'FORM_SID_GUESTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
)
@@ -343,7 +340,7 @@ class acp_board
'email_enable' => array('lang' => 'ENABLE_EMAIL', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true),
'board_email_form' => array('lang' => 'BOARD_EMAIL_FORM', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true),
'email_function_name' => array('lang' => 'EMAIL_FUNCTION_NAME', 'validate' => 'string', 'type' => 'text:20:50', 'explain' => true),
- 'email_package_size' => array('lang' => 'EMAIL_PACKAGE_SIZE', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true),
+ 'email_package_size' => array('lang' => 'EMAIL_PACKAGE_SIZE', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true),
'board_contact' => array('lang' => 'CONTACT_EMAIL', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => true),
'board_email' => array('lang' => 'ADMIN_EMAIL', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => true),
'board_email_sig' => array('lang' => 'EMAIL_SIG', 'validate' => 'string', 'type' => 'textarea:5:30', 'explain' => true),
@@ -352,7 +349,7 @@ class acp_board
'legend2' => 'SMTP_SETTINGS',
'smtp_delivery' => array('lang' => 'USE_SMTP', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'smtp_host' => array('lang' => 'SMTP_SERVER', 'validate' => 'string', 'type' => 'text:25:50', 'explain' => false),
- 'smtp_port' => array('lang' => 'SMTP_PORT', 'validate' => 'int', 'type' => 'text:4:5', 'explain' => true),
+ 'smtp_port' => array('lang' => 'SMTP_PORT', 'validate' => 'int:0', 'type' => 'text:4:5', 'explain' => true),
'smtp_auth_method' => array('lang' => 'SMTP_AUTH_METHOD', 'validate' => 'string', 'type' => 'select', 'method' => 'mail_auth_select', 'explain' => true),
'smtp_username' => array('lang' => 'SMTP_USERNAME', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true),
'smtp_password' => array('lang' => 'SMTP_PASSWORD', 'validate' => 'string', 'type' => 'password:25:255', 'explain' => true)
@@ -555,7 +552,14 @@ class acp_board
{
$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
-
+
+ $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
+
+ if (empty($content))
+ {
+ continue;
+ }
+
$template->assign_block_vars('options', array(
'KEY' => $config_key,
'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
@@ -564,7 +568,7 @@ class acp_board
'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars),
)
);
-
+
unset($display_vars['vars'][$config_key]);
}
@@ -795,7 +799,7 @@ class acp_board
}
$dateformat_options .= 'lang['dateformats'])))
+ if (!isset($user->lang['dateformats'][$value]))
{
$dateformat_options .= ' selected="selected"';
}
diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php
index bb8f437b80..99e53b8667 100644
--- a/phpBB/includes/acp/acp_forums.php
+++ b/phpBB/includes/acp/acp_forums.php
@@ -132,6 +132,7 @@ class acp_forums
'forum_rules_link' => request_var('forum_rules_link', ''),
'forum_image' => request_var('forum_image', ''),
'forum_style' => request_var('forum_style', 0),
+ 'display_subforum_list' => request_var('display_subforum_list', false),
'display_on_index' => request_var('display_on_index', false),
'forum_topics_per_page' => request_var('topics_per_page', 0),
'enable_indexing' => request_var('enable_indexing', true),
@@ -471,6 +472,7 @@ class acp_forums
'forum_rules_link' => '',
'forum_image' => '',
'forum_style' => 0,
+ 'display_subforum_list' => true,
'display_on_index' => false,
'forum_topics_per_page' => 0,
'enable_indexing' => true,
@@ -670,6 +672,7 @@ class acp_forums
'S_FORUM_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false,
'S_ENABLE_INDEXING' => ($forum_data['enable_indexing']) ? true : false,
'S_TOPIC_ICONS' => ($forum_data['enable_icons']) ? true : false,
+ 'S_DISPLAY_SUBFORUM_LIST' => ($forum_data['display_subforum_list']) ? true : false,
'S_DISPLAY_ON_INDEX' => ($forum_data['display_on_index']) ? true : false,
'S_PRUNE_ENABLE' => ($forum_data['enable_prune']) ? true : false,
'S_FORUM_LINK_TRACK' => ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? true : false,
@@ -915,6 +918,13 @@ class acp_forums
$forum_data['prune_days'] = $forum_data['prune_viewed'] = $forum_data['prune_freq'] = 0;
$errors[] = $user->lang['FORUM_DATA_NEGATIVE'];
}
+
+ $range_test_ary = array(
+ array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data['forum_topics_per_page'], 'column_type' => 'TINT:0'),
+ );
+ validate_range($range_test_ary, $errors);
+
+
// Set forum flags
// 1 = link tracking
diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php
index 537c0425a2..f66f45cd36 100644
--- a/phpBB/includes/acp/acp_icons.php
+++ b/phpBB/includes/acp/acp_icons.php
@@ -337,11 +337,16 @@ class acp_icons
}
$icons_updated = 0;
+ $errors = array();
foreach ($images as $image)
{
- if (($mode == 'smilies' && ($image_emotion[$image] == '' || $image_code[$image] == '')) ||
- ($action == 'create' && !isset($image_add[$image])))
+ if ($mode == 'smilies' && ($image_emotion[$image] == '' || $image_code[$image] == ''))
{
+ $errors[$image] = 'SMILIE_NO_' . (($image_emotion[$image] == '') ? 'EMOTION' : 'CODE');
+ }
+ else if ($action == 'create' && !isset($image_add[$image]))
+ {
+ // skip images where add wasn't checked
}
else
{
@@ -431,13 +436,18 @@ class acp_icons
default:
$suc_lang = $lang;
}
+ $errormsgs = ' ';
+ foreach ($errors as $img => $error)
+ {
+ $errormsgs .= ' ' . sprintf($user->lang[$error], $img);
+ }
if ($action == 'modify')
{
- trigger_error($user->lang[$suc_lang . '_EDITED'] . adm_back_link($this->u_action), $level);
+ trigger_error($user->lang[$suc_lang . '_EDITED'] . $errormsgs . adm_back_link($this->u_action), $level);
}
else
{
- trigger_error($user->lang[$suc_lang . '_ADDED'] . adm_back_link($this->u_action), $level);
+ trigger_error($user->lang[$suc_lang . '_ADDED'] . $errormsgs .adm_back_link($this->u_action), $level);
}
break;
@@ -462,7 +472,7 @@ class acp_icons
if (preg_match_all("#'(.*?)', ?#", $pak_entry, $data))
{
if ((sizeof($data[1]) != 4 && $mode == 'icons') ||
- (sizeof($data[1]) != 6 && $mode == 'smilies'))
+ ((sizeof($data[1]) != 6 || (empty($data[1][4]) || empty($data[1][5]))) && $mode == 'smilies' ))
{
trigger_error($user->lang['WRONG_PAK_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php
index d41e1f4a62..be337a20f3 100644
--- a/phpBB/includes/acp/acp_main.php
+++ b/phpBB/includes/acp/acp_main.php
@@ -310,8 +310,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']))
@@ -325,10 +325,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
{
@@ -392,7 +389,7 @@ class acp_main
'DATABASE_INFO' => $db->sql_server_info(),
'BOARD_VERSION' => $config['version'],
- 'U_ACTION' => append_sid("{$phpbb_admin_path}index.$phpEx"),
+ 'U_ACTION' => $this->u_action,
'U_ADMIN_LOG' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=logs&mode=admin'),
'U_INACTIVE_USERS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=inactive&mode=list'),
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,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 = '';
diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php
index 308f83387c..a82a438db7 100644
--- a/phpBB/includes/acp/acp_prune.php
+++ b/phpBB/includes/acp/acp_prune.php
@@ -405,7 +405,15 @@ class acp_prune
$where_sql .= ($email) ? ' AND user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : '';
$where_sql .= (sizeof($joined)) ? " AND user_regdate " . $key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]) : '';
$where_sql .= ($count !== '') ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : '';
- $where_sql .= (sizeof($active)) ? " AND user_lastvisit " . $key_match[$active_select] . " " . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]) : '';
+
+ if (sizeof($active) && $active_select != 'lt')
+ {
+ $where_sql .= ' AND user_lastvisit ' . $key_match[$active_select] . ' ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]);
+ }
+ else if (sizeof($active))
+ {
+ $where_sql .= ' AND (user_lastvisit > 0 AND user_lastvisit < ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]) . ')';
+ }
}
// Protect the admin, do not prune if no options are given...
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php
index 65634ebb25..dc6f3d1c44 100644
--- a/phpBB/includes/acp/acp_search.php
+++ b/phpBB/includes/acp/acp_search.php
@@ -183,6 +183,26 @@ class acp_search
}
}
+ $search = null;
+ $error = false;
+ if (!$this->init_search($config['search_type'], $search, $error))
+ {
+ if ($updated)
+ {
+ if (method_exists($search, 'config_updated'))
+ {
+ if ($search->config_updated())
+ {
+ trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
+ }
+ }
+ }
+ }
+ else
+ {
+ trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
+ }
+
trigger_error($user->lang['CONFIG_UPDATED'] . $extra_message . adm_back_link($this->u_action));
}
unset($cfg_array);
@@ -518,9 +538,9 @@ class acp_search
function close_popup_js()
{
return "\n";
}
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index 31e99a6b0c..88850d59b3 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 260acbbc52..32bbe4e46d 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -411,7 +411,7 @@ class acp_users
$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE user_id = $user_id";
$db->sql_query($sql);
-
+
add_log('admin', 'LOG_USER_DEL_SIG', $user_row['username']);
add_log('user', $user_id, 'LOG_USER_DEL_SIG_USER');
@@ -492,9 +492,9 @@ class acp_users
'update' => true))
);
}
-
+
break;
-
+
case 'moveposts':
if (!check_form_key($form_name))
@@ -630,7 +630,7 @@ class acp_users
}
$forum_id_ary = array_unique($forum_id_ary);
- $topic_id_ary = array_unique(array_merge($topic_id_ary, $new_topic_id_ary));
+ $topic_id_ary = array_unique(array_merge(array_keys($topic_id_ary), $new_topic_id_ary));
if (sizeof($topic_id_ary))
{
@@ -835,9 +835,9 @@ class acp_users
{
$quick_tool_ary += array('active' => (($user_row['user_type'] == USER_INACTIVE) ? 'ACTIVATE' : 'DEACTIVATE'));
}
-
+
$quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH');
-
+
if ($config['email_enable'] && ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_INACTIVE))
{
$quick_tool_ary['reactivate'] = 'FORCE';
@@ -923,7 +923,7 @@ class acp_users
case 'feedback':
$user->add_lang('mcp');
-
+
// Set up general vars
$start = request_var('start', 0);
$deletemark = (isset($_POST['delmarked'])) ? true : false;
@@ -980,7 +980,7 @@ class acp_users
trigger_error($user->lang['USER_FEEDBACK_ADDED'] . adm_back_link($this->u_action . '&u=' . $user_id));
}
-
+
// Sorting
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
@@ -1060,9 +1060,11 @@ class acp_users
list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']);
}
- $data['bday_day'] = request_var('bday_day', $data['bday_day']);
- $data['bday_month'] = request_var('bday_month', $data['bday_month']);
- $data['bday_year'] = request_var('bday_year', $data['bday_year']);
+ $data['bday_day'] = request_var('bday_day', $data['bday_day']);
+ $data['bday_month'] = request_var('bday_month', $data['bday_month']);
+ $data['bday_year'] = request_var('bday_year', $data['bday_year']);
+ $data['user_birthday'] = sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']);
+
if ($submit)
{
@@ -1085,6 +1087,7 @@ class acp_users
'bday_day' => array('num', true, 1, 31),
'bday_month' => array('num', true, 1, 12),
'bday_year' => array('num', true, 1901, gmdate('Y', time())),
+ 'user_birthday' => array('date', true),
));
// validate custom profile fields
@@ -1111,7 +1114,7 @@ class acp_users
'user_from' => $data['location'],
'user_occ' => $data['occupation'],
'user_interests'=> $data['interests'],
- 'user_birthday' => sprintf('%2d-%2d-%4d', $data['bday_day'], $data['bday_month'], $data['bday_year']),
+ 'user_birthday' => $data['user_birthday'],
);
$sql = 'UPDATE ' . USERS_TABLE . '
@@ -1213,7 +1216,7 @@ class acp_users
'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options,
'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options,
'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options,
-
+
'S_PROFILE' => true)
);
@@ -1344,7 +1347,7 @@ class acp_users
$s_custom = false;
$dateformat_options .= ' lang['dateformats'])))
+ if (!isset($user->lang['dateformats'][$data['dateformat']]))
{
$dateformat_options .= ' selected="selected"';
$s_custom = true;
@@ -1392,7 +1395,7 @@ class acp_users
$template->assign_vars(array(
'S_PREFS' => true,
'S_JABBER_DISABLED' => ($config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml')) ? false : true,
-
+
'VIEW_EMAIL' => $data['viewemail'],
'MASS_EMAIL' => $data['massemail'],
'ALLOW_PM' => $data['allowpm'],
@@ -1413,7 +1416,7 @@ class acp_users
'VIEW_SIGS' => $data['view_sigs'],
'VIEW_AVATARS' => $data['view_avatars'],
'VIEW_WORDCENSOR' => $data['view_wordcensor'],
-
+
'S_TOPIC_SORT_DAYS' => $s_limit_topic_days,
'S_TOPIC_SORT_KEY' => $s_sort_topic_key,
'S_TOPIC_SORT_DIR' => $s_sort_topic_dir,
@@ -1506,7 +1509,7 @@ class acp_users
trigger_error($user->lang['USER_RANK_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
}
-
+
$sql = 'SELECT *
FROM ' . RANKS_TABLE . '
WHERE rank_special = 1
@@ -1528,9 +1531,9 @@ class acp_users
);
break;
-
+
case 'sig':
-
+
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
@@ -1549,7 +1552,7 @@ class acp_users
// Allowing Quote BBCode
$message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $config['allow_sig_img'], $config['allow_sig_flash'], true, $config['allow_sig_links'], true, 'sig');
-
+
if (sizeof($message_parser->warn_msg))
{
$error[] = implode(' ', $message_parser->warn_msg);
@@ -1575,13 +1578,13 @@ class acp_users
trigger_error($user->lang['USER_SIG_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id));
}
-
+
// Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
}
-
+
$signature_preview = '';
-
+
if ($preview)
{
// Now parse it for displaying
@@ -1744,7 +1747,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'],
@@ -1752,7 +1755,7 @@ class acp_users
'ATTACH_ID' => $row['attach_id'],
'POST_ID' => $row['post_msg_id'],
'TOPIC_ID' => $row['topic_id'],
-
+
'S_IN_MESSAGE' => $row['in_message'],
'U_DOWNLOAD' => append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . $row['attach_id']),
@@ -1760,7 +1763,7 @@ class acp_users
);
}
$db->sql_freeresult($result);
-
+
$template->assign_vars(array(
'S_ATTACHMENTS' => true,
'S_ON_PAGE' => on_page($num_attachments, $config['topics_per_page'], $start),
@@ -1771,14 +1774,14 @@ class acp_users
);
break;
-
+
case 'groups':
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
$user->add_lang(array('groups', 'acp/groups'));
$group_id = request_var('g', 0);
-
+
if ($group_id)
{
// Check the founder only entry for this group to make sure everything is well
@@ -1788,7 +1791,7 @@ class acp_users
$result = $db->sql_query($sql);
$founder_manage = (int) $db->sql_fetchfield('group_founder_manage');
$db->sql_freeresult($result);
-
+
if ($user->data['user_type'] != USER_FOUNDER && $founder_manage)
{
trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
@@ -1798,7 +1801,7 @@ class acp_users
{
$founder_manage = 0;
}
-
+
switch ($action)
{
case 'demote':
@@ -1829,7 +1832,7 @@ class acp_users
{
trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
-
+
$error = array();
}
else
@@ -1842,7 +1845,7 @@ class acp_users
'g' => $group_id))
);
}
-
+
break;
}
@@ -1977,7 +1980,7 @@ class acp_users
$result = $db->sql_query($sql);
$hold_ary = array();
-
+
while ($row = $db->sql_fetchrow($result))
{
$hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', ACL_NEVER);
@@ -2017,7 +2020,7 @@ class acp_users
'U_USER_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx" ,'i=permissions&mode=setting_user_global&user_id[]=' . $user_id),
'U_USER_FORUM_PERMISSIONS' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions&mode=setting_user_local&user_id[]=' . $user_id))
);
-
+
break;
}
diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php
index b4ea0e46d0..6943f5ada1 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);
}
@@ -778,6 +765,10 @@ class auth_admin extends auth
$cache->destroy('_acl_options');
$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->acl_options = array();
+ $this->auth_admin();
+
return true;
}
@@ -813,7 +804,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]))
@@ -825,7 +816,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
@@ -888,7 +879,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)
{
@@ -944,7 +935,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)
{
@@ -961,7 +952,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
);
}
@@ -1238,13 +1229,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
@@ -1252,12 +1238,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);
diff --git a/phpBB/includes/auth.php b/phpBB/includes/auth.php
index c965149018..8dd15fea64 100644
--- a/phpBB/includes/auth.php
+++ b/phpBB/includes/auth.php
@@ -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);
@@ -302,7 +305,14 @@ class auth
*/
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)
@@ -332,12 +342,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
@@ -348,42 +353,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)
@@ -420,15 +394,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;
}
@@ -466,8 +440,31 @@ class auth
*/
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,24 +561,62 @@ class auth
while ($row = $db->sql_fetchrow($result))
{
- 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))
+ $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']];
+
+ 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;
}
+*/
}
}
}
@@ -671,45 +638,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;
}
@@ -725,49 +690,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.
+ */
+ 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
+ */
+ 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.
*/
diff --git a/phpBB/includes/auth/auth_apache.php b/phpBB/includes/auth/auth_apache.php
index ed3951dd7b..4581a1bbdb 100644
--- a/phpBB/includes/auth/auth_apache.php
+++ b/phpBB/includes/auth/auth_apache.php
@@ -48,8 +48,18 @@ function login_apache(&$username, &$password)
if (!$password)
{
return array(
- 'status' => LOGIN_BREAK,
+ 'status' => LOGIN_ERROR_PASSWORD,
'error_msg' => 'NO_PASSWORD_SUPPLIED',
+ 'user_row' => array('user_id' => ANONYMOUS),
+ );
+ }
+
+ if (!$username)
+ {
+ return array(
+ 'status' => LOGIN_ERROR_USERNAME,
+ 'error_msg' => 'LOGIN_ERROR_USERNAME',
+ 'user_row' => array('user_id' => ANONYMOUS),
);
}
diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php
index 432ae92d21..1a5fd9e418 100644
--- a/phpBB/includes/auth/auth_db.php
+++ b/phpBB/includes/auth/auth_db.php
@@ -32,8 +32,18 @@ function login_db(&$username, &$password)
if (!$password)
{
return array(
- 'status' => LOGIN_BREAK,
+ 'status' => LOGIN_ERROR_PASSWORD,
'error_msg' => 'NO_PASSWORD_SUPPLIED',
+ 'user_row' => array('user_id' => ANONYMOUS),
+ );
+ }
+
+ if (!$username)
+ {
+ return array(
+ 'status' => LOGIN_ERROR_USERNAME,
+ 'error_msg' => 'LOGIN_ERROR_USERNAME',
+ 'user_row' => array('user_id' => ANONYMOUS),
);
}
diff --git a/phpBB/includes/auth/auth_ldap.php b/phpBB/includes/auth/auth_ldap.php
index 472927ace3..d49662fb2d 100644
--- a/phpBB/includes/auth/auth_ldap.php
+++ b/phpBB/includes/auth/auth_ldap.php
@@ -104,8 +104,18 @@ function login_ldap(&$username, &$password)
if (!$password)
{
return array(
- 'status' => LOGIN_BREAK,
+ 'status' => LOGIN_ERROR_PASSWORD,
'error_msg' => 'NO_PASSWORD_SUPPLIED',
+ 'user_row' => array('user_id' => ANONYMOUS),
+ );
+ }
+
+ if (!$username)
+ {
+ return array(
+ 'status' => LOGIN_ERROR_USERNAME,
+ 'error_msg' => 'LOGIN_ERROR_USERNAME',
+ 'user_row' => array('user_id' => ANONYMOUS),
);
}
diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php
index 8257f8a48e..eb4eb77f22 100644
--- a/phpBB/includes/constants.php
+++ b/phpBB/includes/constants.php
@@ -173,7 +173,7 @@ define('FIELD_DATE', 6);
// Additional constants
-define('VOTE_CONVERTED', 9999);
+define('VOTE_CONVERTED', 127);
// Table names
define('ACL_GROUPS_TABLE', $table_prefix . 'acl_groups');
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index e37ccda0db..21d095155e 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -45,7 +45,9 @@ class dbal
// Holding the last sql query on sql error
var $sql_error_sql = '';
-
+ // Holding the error information - only populated if sql_error_triggered is set
+ var $sql_error_returned = array();
+
// Holding transaction count
var $transactions = 0;
@@ -262,6 +264,13 @@ class dbal
return true;
}
+ // Check if there is a transaction (no transaction can happen if there was an error, with a combined rollback and error returning enabled)
+ // This implies we have transaction always set for autocommit db's
+ if (!$this->transaction)
+ {
+ return false;
+ }
+
$result = $this->_sql_transaction('commit');
if (!$result)
@@ -537,11 +546,11 @@ class dbal
$this->sql_error_triggered = true;
$this->sql_error_sql = $sql;
- $error = $this->_sql_error();
+ $this->sql_error_returned = $this->_sql_error();
if (!$this->return_on_error)
{
- $message = 'SQL ERROR [ ' . $this->sql_layer . ' ] ' . $error['message'] . ' [' . $error['code'] . ']';
+ $message = 'SQL ERROR [ ' . $this->sql_layer . ' ] ' . $this->sql_error_returned['message'] . ' [' . $this->sql_error_returned['code'] . ']';
// Show complete SQL error and path to administrators only
// Additionally show complete error on installation or if extended debug mode is enabled
@@ -598,7 +607,7 @@ class dbal
$this->sql_transaction('rollback');
}
- return $error;
+ return $this->sql_error_returned;
}
/**
diff --git a/phpBB/includes/diff/renderer.php b/phpBB/includes/diff/renderer.php
index 4157bc2cde..f4a0bce3f9 100644
--- a/phpBB/includes/diff/renderer.php
+++ b/phpBB/includes/diff/renderer.php
@@ -301,7 +301,7 @@ class diff_renderer_unified extends diff_renderer
{
return '' . htmlspecialchars($this->_lines($lines, ' ')) . ' ';
}
-
+
function _added($lines)
{
return '' . htmlspecialchars($this->_lines($lines, '+')) . ' ';
@@ -448,7 +448,7 @@ class diff_renderer_inline extends diff_renderer
// Therefore we split on words, but include all blocks of whitespace in the wordlist.
$splitted_text_1 = $this->_split_on_words($text1, $nl);
$splitted_text_2 = $this->_split_on_words($text2, $nl);
-
+
$diff = &new diff($splitted_text_1, $splitted_text_2);
unset($splitted_text_1, $splitted_text_2);
@@ -463,7 +463,7 @@ class diff_renderer_inline extends diff_renderer
{
// Ignore \0; otherwise the while loop will never finish.
$string = str_replace("\0", '', $string);
-
+
$words = array();
$length = strlen($string);
$pos = 0;
@@ -537,7 +537,7 @@ class diff_renderer_raw extends diff_renderer
{
return $this->_lines($lines, ' ');
}
-
+
function _added($lines)
{
return $this->_lines($lines, '+');
@@ -603,7 +603,7 @@ class diff_renderer_side_by_side extends diff_renderer
// Iterate through every header block of changes
foreach ($this->lines as $header)
{
- $output .= 'Line ' . $header['oldline'] . ' ' . $user->lang['LINE'] . ' ' . $header['newline'] . ' ';
+ $output .= '' . $user->lang['LINE'] . ' ' . $header['oldline'] . ' ' . $user->lang['LINE'] . ' ' . $header['newline'] . ' ';
// Each header block consists of a number of changes (add, remove, change).
$current_context = '';
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index bf00beb2e1..e61df309b3 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -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.
@@ -287,7 +307,7 @@ function phpbb_hash($password)
}
$random = substr($random, 0, $count);
}
-
+
$hash = _hash_crypt_private($password, _hash_gensalt_private($random, $itoa64), $itoa64);
if (strlen($hash) == 34)
@@ -360,7 +380,7 @@ function _hash_encode64($input, $count, &$itoa64)
}
$output .= $itoa64[($value >> 12) & 0x3f];
-
+
if ($i++ >= $count)
{
break;
@@ -523,177 +543,175 @@ if (!function_exists('stripos'))
}
}
-if (!function_exists('realpath'))
+/**
+* Checks if a path ($path) is absolute or relative
+*
+* @param string $path Path to check absoluteness of
+* @return boolean
+*/
+function is_absolute($path)
{
- /**
- * Checks if a path ($path) is absolute or relative
- *
- * @param string $path Path to check absoluteness of
- * @return boolean
- */
- function is_absolute($path)
+ return ($path[0] == '/' || (DIRECTORY_SEPARATOR == '\\' && preg_match('#^[a-z]:/#i', $path))) ? true : false;
+}
+
+/**
+* @author Chris Smith
+* @copyright 2006 Project Minerva Team
+* @param string $path The path which we should attempt to resolve.
+* @return mixed
+*/
+function phpbb_own_realpath($path)
+{
+ // Now to perform funky shizzle
+
+ // Switch to use UNIX slashes
+ $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
+ $path_prefix = '';
+
+ // Determine what sort of path we have
+ if (is_absolute($path))
{
- return ($path[0] == '/' || (DIRECTORY_SEPARATOR == '\\' && preg_match('#^[a-z]:/#i', $path))) ? true : false;
- }
+ $absolute = true;
- /**
- * @author Chris Smith
- * @copyright 2006 Project Minerva Team
- * @param string $path The path which we should attempt to resolve.
- * @return mixed
- */
- function phpbb_realpath($path)
- {
- // Now to perform funky shizzle
-
- // Switch to use UNIX slashes
- $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
- $path_prefix = '';
-
- // Determine what sort of path we have
- if (is_absolute($path))
+ if ($path[0] == '/')
{
+ // Absolute path, *NIX style
+ $path_prefix = '';
+ }
+ else
+ {
+ // Absolute path, Windows style
+ // Remove the drive letter and colon
+ $path_prefix = $path[0] . ':';
+ $path = substr($path, 2);
+ }
+ }
+ else
+ {
+ // Relative Path
+ // Prepend the current working directory
+ if (function_exists('getcwd'))
+ {
+ // This is the best method, hopefully it is enabled!
+ $path = str_replace(DIRECTORY_SEPARATOR, '/', getcwd()) . '/' . $path;
$absolute = true;
-
- if ($path[0] == '/')
+ if (preg_match('#^[a-z]:#i', $path))
{
- // Absolute path, *NIX style
- $path_prefix = '';
+ $path_prefix = $path[0] . ':';
+ $path = substr($path, 2);
}
else
{
- // Absolute path, Windows style
- // Remove the drive letter and colon
- $path_prefix = $path[0] . ':';
- $path = substr($path, 2);
+ $path_prefix = '';
+ }
+ }
+ else if (isset($_SERVER['SCRIPT_FILENAME']) && !empty($_SERVER['SCRIPT_FILENAME']))
+ {
+ // Warning: If chdir() has been used this will lie!
+ // Warning: This has some problems sometime (CLI can create them easily)
+ $path = str_replace(DIRECTORY_SEPARATOR, '/', dirname($_SERVER['SCRIPT_FILENAME'])) . '/' . $path;
+ $absolute = true;
+ $path_prefix = '';
+ }
+ else
+ {
+ // We have no way of getting the absolute path, just run on using relative ones.
+ $absolute = false;
+ $path_prefix = '.';
+ }
+ }
+
+ // Remove any repeated slashes
+ $path = preg_replace('#/{2,}#', '/', $path);
+
+ // Remove the slashes from the start and end of the path
+ $path = trim($path, '/');
+
+ // Break the string into little bits for us to nibble on
+ $bits = explode('/', $path);
+
+ // Remove any . in the path, renumber array for the loop below
+ $bits = array_values(array_diff($bits, array('.')));
+
+ // Lets get looping, run over and resolve any .. (up directory)
+ for ($i = 0, $max = sizeof($bits); $i < $max; $i++)
+ {
+ // @todo Optimise
+ if ($bits[$i] == '..' )
+ {
+ if (isset($bits[$i - 1]))
+ {
+ if ($bits[$i - 1] != '..')
+ {
+ // We found a .. and we are able to traverse upwards, lets do it!
+ unset($bits[$i]);
+ unset($bits[$i - 1]);
+ $i -= 2;
+ $max -= 2;
+ $bits = array_values($bits);
+ }
+ }
+ else if ($absolute) // ie. !isset($bits[$i - 1]) && $absolute
+ {
+ // We have an absolute path trying to descend above the root of the filesystem
+ // ... Error!
+ return false;
+ }
+ }
+ }
+
+ // Prepend the path prefix
+ array_unshift($bits, $path_prefix);
+
+ $resolved = '';
+
+ $max = sizeof($bits) - 1;
+
+ // Check if we are able to resolve symlinks, Windows cannot.
+ $symlink_resolve = (function_exists('readlink')) ? true : false;
+
+ foreach ($bits as $i => $bit)
+ {
+ if (@is_dir("$resolved/$bit") || ($i == $max && @is_file("$resolved/$bit")))
+ {
+ // Path Exists
+ if ($symlink_resolve && is_link("$resolved/$bit") && ($link = readlink("$resolved/$bit")))
+ {
+ // Resolved a symlink.
+ $resolved = $link . (($i == $max) ? '' : '/');
+ continue;
}
}
else
{
- // Relative Path
- // Prepend the current working directory
- if (function_exists('getcwd'))
- {
- // This is the best method, hopefully it is enabled!
- $path = str_replace(DIRECTORY_SEPARATOR, '/', getcwd()) . '/' . $path;
- $absolute = true;
- if (preg_match('#^[a-z]:#i', $path))
- {
- $path_prefix = $path[0] . ':';
- $path = substr($path, 2);
- }
- else
- {
- $path_prefix = '';
- }
- }
- else if (isset($_SERVER['SCRIPT_FILENAME']) && !empty($_SERVER['SCRIPT_FILENAME']))
- {
- // Warning: If chdir() has been used this will lie!
- // Warning: This has some problems sometime (CLI can create them easily)
- $path = str_replace(DIRECTORY_SEPARATOR, '/', dirname($_SERVER['SCRIPT_FILENAME'])) . '/' . $path;
- $absolute = true;
- $path_prefix = '';
- }
- else
- {
- // We have no way of getting the absolute path, just run on using relative ones.
- $absolute = false;
- $path_prefix = '.';
- }
+ // Something doesn't exist here!
+ // This is correct realpath() behaviour but sadly open_basedir and safe_mode make this problematic
+ // return false;
}
-
- // Remove any repeated slashes
- $path = preg_replace('#/{2,}#', '/', $path);
-
- // Remove the slashes from the start and end of the path
- $path = trim($path, '/');
-
- // Break the string into little bits for us to nibble on
- $bits = explode('/', $path);
-
- // Remove any . in the path, renumber array for the loop below
- $bits = array_values(array_diff($bits, array('.')));
-
- // Lets get looping, run over and resolve any .. (up directory)
- for ($i = 0, $max = sizeof($bits); $i < $max; $i++)
- {
- // @todo Optimise
- if ($bits[$i] == '..' )
- {
- if (isset($bits[$i - 1]))
- {
- if ($bits[$i - 1] != '..')
- {
- // We found a .. and we are able to traverse upwards, lets do it!
- unset($bits[$i]);
- unset($bits[$i - 1]);
- $i -= 2;
- $max -= 2;
- $bits = array_values($bits);
- }
- }
- else if ($absolute) // ie. !isset($bits[$i - 1]) && $absolute
- {
- // We have an absolute path trying to descend above the root of the filesystem
- // ... Error!
- return false;
- }
- }
- }
-
- // Prepend the path prefix
- array_unshift($bits, $path_prefix);
-
- $resolved = '';
-
- $max = sizeof($bits) - 1;
-
- // Check if we are able to resolve symlinks, Windows cannot.
- $symlink_resolve = (function_exists('readlink')) ? true : false;
-
- foreach ($bits as $i => $bit)
- {
- if (@is_dir("$resolved/$bit") || ($i == $max && @is_file("$resolved/$bit")))
- {
- // Path Exists
- if ($symlink_resolve && is_link("$resolved/$bit") && ($link = readlink("$resolved/$bit")))
- {
- // Resolved a symlink.
- $resolved = $link . (($i == $max) ? '' : '/');
- continue;
- }
- }
- else
- {
- // Something doesn't exist here!
- // This is correct realpath() behaviour but sadly open_basedir and safe_mode make this problematic
- // return false;
- }
- $resolved .= $bit . (($i == $max) ? '' : '/');
- }
-
- // @todo If the file exists fine and open_basedir only has one path we should be able to prepend it
- // because we must be inside that basedir, the question is where...
- // @internal The slash in is_dir() gets around an open_basedir restriction
- if (!@file_exists($resolved) || (!is_dir($resolved . '/') && !is_file($resolved)))
- {
- return false;
- }
-
- // Put the slashes back to the native operating systems slashes
- $resolved = str_replace('/', DIRECTORY_SEPARATOR, $resolved);
-
- // Check for DIRECTORY_SEPARATOR at the end (and remove it!)
- if (substr($resolved, -1) == DIRECTORY_SEPARATOR)
- {
- return substr($resolved, 0, -1);
- }
-
- return $resolved; // We got here, in the end!
+ $resolved .= $bit . (($i == $max) ? '' : '/');
}
+
+ // @todo If the file exists fine and open_basedir only has one path we should be able to prepend it
+ // because we must be inside that basedir, the question is where...
+ // @internal The slash in is_dir() gets around an open_basedir restriction
+ if (!@file_exists($resolved) || (!is_dir($resolved . '/') && !is_file($resolved)))
+ {
+ return false;
+ }
+
+ // Put the slashes back to the native operating systems slashes
+ $resolved = str_replace('/', DIRECTORY_SEPARATOR, $resolved);
+
+ // Check for DIRECTORY_SEPARATOR at the end (and remove it!)
+ if (substr($resolved, -1) == DIRECTORY_SEPARATOR)
+ {
+ return substr($resolved, 0, -1);
+ }
+
+ return $resolved; // We got here, in the end!
}
-else
+
+if (!function_exists('realpath'))
{
/**
* A wrapper for realpath
@@ -701,15 +719,32 @@ else
*/
function phpbb_realpath($path)
{
- $path = realpath($path);
+ return phpbb_own_realpath($path);
+ }
+}
+else
+{
+ /**
+ * A wrapper for realpath
+ */
+ function phpbb_realpath($path)
+ {
+ $realpath = realpath($path);
- // Check for DIRECTORY_SEPARATOR at the end (and remove it!)
- if (substr($path, -1) == DIRECTORY_SEPARATOR)
+ // Strangely there are provider not disabling realpath but returning strange values. :o
+ // We at least try to cope with them.
+ if ($realpath === $path || $realpath === false)
{
- return substr($path, 0, -1);
+ return phpbb_own_realpath($path);
}
- return $path;
+ // Check for DIRECTORY_SEPARATOR at the end (and remove it!)
+ if (substr($realpath, -1) == DIRECTORY_SEPARATOR)
+ {
+ $realpath = substr($realpath, 0, -1);
+ }
+
+ return $realpath;
}
}
@@ -836,7 +871,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
unset($tracking_topics['t']);
unset($tracking_topics['f']);
$tracking_topics['l'] = base_convert(time() - $config['board_startdate'], 10, 36);
-
+
$user->set_cookie('track', tracking_serialize($tracking_topics), time() + 31536000);
$_COOKIE[$config['cookie_name'] . '_track'] = (STRIP) ? addslashes(tracking_serialize($tracking_topics)) : tracking_serialize($tracking_topics);
@@ -1129,7 +1164,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $
{
$mark_time[$forum_id] = $forum_mark_time[$forum_id];
}
-
+
$user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user->data['user_lastmark'];
foreach ($topic_ids as $topic_id)
@@ -1177,7 +1212,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
$last_read[$row['topic_id']] = $row['mark_time'];
}
$db->sql_freeresult($result);
-
+
$topic_ids = array_diff($topic_ids, array_keys($last_read));
if (sizeof($topic_ids))
@@ -1188,7 +1223,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
AND forum_id " .
(($global_announce_list && sizeof($global_announce_list)) ? "IN (0, $forum_id)" : "= $forum_id");
$result = $db->sql_query($sql);
-
+
$mark_time = array();
while ($row = $db->sql_fetchrow($result))
{
@@ -1359,7 +1394,7 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti
while ($row = $db->sql_fetchrow($result))
{
- if (!in_array(base_convert($row['topic_id'], 10, 36), array_keys($check_forum)))
+ if (!isset($check_forum[base_convert($row['topic_id'], 10, 36)]))
{
$unread = true;
break;
@@ -1459,7 +1494,7 @@ function tracking_unserialize($string, $max_depth = 3)
break;
}
break;
-
+
case 2:
switch ($string[$i])
{
@@ -1477,7 +1512,7 @@ function tracking_unserialize($string, $max_depth = 3)
break;
}
break;
-
+
case 3:
switch ($string[$i])
{
@@ -1501,7 +1536,7 @@ function tracking_unserialize($string, $max_depth = 3)
{
die('Invalid data supplied');
}
-
+
return $level;
}
@@ -1719,7 +1754,7 @@ function generate_board_url($without_script_path = false)
{
global $config, $user;
- $server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME');
+ $server_name = $user->host;
$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
// Forcing server vars is the only way to specify/override the protocol
@@ -1743,7 +1778,11 @@ function generate_board_url($without_script_path = false)
if ($server_port && (($config['cookie_secure'] && $server_port <> 443) || (!$config['cookie_secure'] && $server_port <> 80)))
{
- $url .= ':' . $server_port;
+ // HTTP HOST can carry a port number...
+ if (strpos($server_name, ':') === false)
+ {
+ $url .= ':' . $server_port;
+ }
}
if (!$without_script_path)
@@ -1984,7 +2023,7 @@ function build_url($strip_vars = false)
unset($query[$strip]);
}
}
-
+
// Glue the remaining parts together... already urlencoded
foreach ($query as $key => $value)
{
@@ -2041,9 +2080,8 @@ function add_form_key($form_name)
* @param int $timespan The maximum acceptable age for a submitted form in seconds. Defaults to the config setting.
* @param string $return_page The address for the return link
* @param bool $trigger If true, the function will triger an error when encountering an invalid form
-* @param int $minimum_time The minimum acceptable age for a submitted form in seconds
*/
-function check_form_key($form_name, $timespan = false, $return_page = '', $trigger = false, $minimum_time = false)
+function check_form_key($form_name, $timespan = false, $return_page = '', $trigger = false)
{
global $config, $user;
@@ -2052,11 +2090,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
// we enforce a minimum value of half a minute here.
$timespan = ($config['form_token_lifetime'] == -1) ? -1 : max(30, $config['form_token_lifetime']);
}
- if ($minimum_time === false)
- {
- $minimum_time = (int) $config['form_token_mintime'];
- }
-
+
if (isset($_POST['creation_time']) && isset($_POST['form_token']))
{
$creation_time = abs(request_var('creation_time', 0));
@@ -2064,10 +2098,10 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
$diff = (time() - $creation_time);
- if (($diff >= $minimum_time) && (($diff <= $timespan) || $timespan == -1))
+ if (($diff <= $timespan) || $timespan === -1)
{
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
-
+
$key = sha1($creation_time . $user->data['user_form_salt'] . $form_name . $token_sid);
if ($key === $token)
{
@@ -2304,7 +2338,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
// Something failed, determine what...
if ($result['status'] == LOGIN_BREAK)
{
- trigger_error($result['error_msg'], E_USER_ERROR);
+ trigger_error($result['error_msg']);
}
// Special cases... determine
@@ -2365,7 +2399,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
{
$err = (!$config['board_contact']) ? sprintf($user->lang[$result['error_msg']], '', '') : sprintf($user->lang[$result['error_msg']], '', ' ');
}
-
+
break;
}
}
@@ -2419,7 +2453,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
'PASSWORD_CREDENTIAL' => ($admin) ? 'password_' . $credential : 'password',
));
- page_header($user->lang['LOGIN']);
+ page_header($user->lang['LOGIN'], false);
$template->set_filenames(array(
'body' => 'login_body.html')
@@ -2502,7 +2536,7 @@ function login_forum_box($forum_data)
$template->set_filenames(array(
'body' => 'login_forum.html')
);
-
+
page_footer();
}
@@ -2601,10 +2635,10 @@ function parse_cfg_file($filename, $lines = false)
{
$value = substr($value, 1, sizeof($value)-2);
}
-
+
$parsed_items[$key] = $value;
}
-
+
return $parsed_items;
}
@@ -2631,13 +2665,13 @@ function add_log()
'log_operation' => $action,
'log_data' => $data,
);
-
+
switch ($mode)
{
case 'admin':
$sql_ary['log_type'] = LOG_ADMIN;
break;
-
+
case 'mod':
$sql_ary += array(
'log_type' => LOG_MOD,
@@ -2656,7 +2690,7 @@ function add_log()
case 'critical':
$sql_ary['log_type'] = LOG_CRITICAL;
break;
-
+
default:
return false;
}
@@ -2737,7 +2771,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':
@@ -2962,14 +2996,14 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
echo '';
echo ' ';
echo '' . $msg_title . ' ';
- echo '';
echo '';
echo '';
@@ -2981,9 +3015,9 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
echo ' ';
echo '
';
echo '
' . $msg_title . ' ';
-
+
echo '
' . $msg_text . '
';
-
+
echo $l_notify;
echo '
';
@@ -2995,7 +3029,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
echo '
';
echo '';
echo '