aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/.htaccess4
-rw-r--r--phpBB/includes/acm/acm_file.php16
-rw-r--r--phpBB/includes/acm/acm_memory.php8
-rw-r--r--phpBB/includes/acp/acp_attachments.php11
-rw-r--r--phpBB/includes/acp/acp_ban.php4
-rw-r--r--phpBB/includes/acp/acp_board.php7
-rw-r--r--phpBB/includes/acp/acp_captcha.php4
-rw-r--r--phpBB/includes/acp/acp_database.php55
-rw-r--r--phpBB/includes/acp/acp_forums.php27
-rw-r--r--phpBB/includes/acp/acp_groups.php11
-rw-r--r--phpBB/includes/acp/acp_php_info.php4
-rw-r--r--phpBB/includes/acp/acp_profile.php1
-rw-r--r--phpBB/includes/acp/acp_prune.php8
-rw-r--r--phpBB/includes/acp/acp_reasons.php1
-rw-r--r--phpBB/includes/acp/acp_styles.php29
-rw-r--r--phpBB/includes/acp/acp_users.php76
-rw-r--r--phpBB/includes/acp/info/acp_board.php2
-rw-r--r--phpBB/includes/auth/auth_db.php6
-rw-r--r--phpBB/includes/auth/auth_ldap.php2
-rw-r--r--phpBB/includes/cache.php9
-rw-r--r--phpBB/includes/captcha/plugins/captcha_abstract.php8
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php5
-rw-r--r--phpBB/includes/constants.php8
-rw-r--r--phpBB/includes/db/db_tools.php18
-rw-r--r--phpBB/includes/db/firebird.php11
-rw-r--r--phpBB/includes/db/mssql.php7
-rw-r--r--phpBB/includes/db/mssql_odbc.php7
-rw-r--r--phpBB/includes/db/mssqlnative.php35
-rw-r--r--phpBB/includes/db/mysql.php7
-rw-r--r--phpBB/includes/db/mysqli.php8
-rw-r--r--phpBB/includes/db/oracle.php15
-rw-r--r--phpBB/includes/db/postgres.php21
-rw-r--r--phpBB/includes/db/sqlite.php11
-rw-r--r--phpBB/includes/functions.php274
-rw-r--r--phpBB/includes/functions_admin.php98
-rw-r--r--phpBB/includes/functions_compress.php6
-rw-r--r--phpBB/includes/functions_convert.php9
-rw-r--r--phpBB/includes/functions_display.php19
-rw-r--r--phpBB/includes/functions_messenger.php7
-rw-r--r--phpBB/includes/functions_posting.php24
-rw-r--r--phpBB/includes/functions_privmsgs.php7
-rw-r--r--phpBB/includes/functions_profile_fields.php6
-rw-r--r--phpBB/includes/functions_upload.php30
-rw-r--r--phpBB/includes/functions_user.php57
-rw-r--r--phpBB/includes/mcp/mcp_main.php35
-rw-r--r--phpBB/includes/mcp/mcp_post.php4
-rw-r--r--phpBB/includes/mcp/mcp_queue.php23
-rw-r--r--phpBB/includes/mcp/mcp_reports.php2
-rw-r--r--phpBB/includes/mcp/mcp_topic.php2
-rw-r--r--phpBB/includes/message_parser.php2
-rw-r--r--phpBB/includes/search/fulltext_mysql.php10
-rw-r--r--phpBB/includes/search/fulltext_native.php13
-rw-r--r--phpBB/includes/session.php23
-rw-r--r--phpBB/includes/ucp/info/ucp_profile.php2
-rw-r--r--phpBB/includes/ucp/ucp_groups.php2
-rw-r--r--phpBB/includes/ucp/ucp_main.php4
-rw-r--r--phpBB/includes/ucp/ucp_pm_compose.php2
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewfolder.php26
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewmessage.php2
-rw-r--r--phpBB/includes/ucp/ucp_profile.php9
-rw-r--r--phpBB/includes/ucp/ucp_register.php6
-rw-r--r--phpBB/includes/ucp/ucp_remind.php4
62 files changed, 854 insertions, 300 deletions
diff --git a/phpBB/includes/.htaccess b/phpBB/includes/.htaccess
new file mode 100644
index 0000000000..4128d345ab
--- /dev/null
+++ b/phpBB/includes/.htaccess
@@ -0,0 +1,4 @@
+<Files *>
+ Order Allow,Deny
+ Deny from All
+</Files>
diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php
index 5a758aa2bb..5c1876d006 100644
--- a/phpBB/includes/acm/acm_file.php
+++ b/phpBB/includes/acm/acm_file.php
@@ -78,8 +78,14 @@ class acm
if (!$this->_write('data_global'))
{
+ if (!function_exists('phpbb_is_writable'))
+ {
+ global $phpbb_root_path;
+ include($phpbb_root_path . 'includes/functions.' . $phpEx);
+ }
+
// Now, this occurred how often? ... phew, just tell the user then...
- if (!@is_writable($this->cache_dir))
+ if (!phpbb_is_writable($this->cache_dir))
{
// We need to use die() here, because else we may encounter an infinite loop (the message handler calls $cache->unload())
die($this->cache_dir . ' is NOT writable.');
@@ -707,7 +713,13 @@ class acm
*/
function remove_file($filename, $check = false)
{
- if ($check && !@is_writable($this->cache_dir))
+ if (!function_exists('phpbb_is_writable'))
+ {
+ global $phpbb_root_path, $phpEx;
+ include($phpbb_root_path . 'includes/functions.' . $phpEx);
+ }
+
+ if ($check && !phpbb_is_writable($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);
diff --git a/phpBB/includes/acm/acm_memory.php b/phpBB/includes/acm/acm_memory.php
index efbfd4dd62..2936ea0bae 100644
--- a/phpBB/includes/acm/acm_memory.php
+++ b/phpBB/includes/acm/acm_memory.php
@@ -407,7 +407,13 @@ class acm_memory
*/
function remove_file($filename, $check = false)
{
- if ($check && !@is_writable($this->cache_dir))
+ if (!function_exists('phpbb_is_writable'))
+ {
+ global $phpbb_root_path, $phpEx;
+ include($phpbb_root_path . 'includes/functions.' . $phpEx);
+ }
+
+ if ($check && !phpbb_is_writable($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);
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php
index 25e51814c4..fc5f44e14f 100644
--- a/phpBB/includes/acp/acp_attachments.php
+++ b/phpBB/includes/acp/acp_attachments.php
@@ -90,6 +90,7 @@ class acp_attachments
$s_assigned_groups = array();
while ($row = $db->sql_fetchrow($result))
{
+ $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'];
$s_assigned_groups[$row['cat_id']][] = $row['group_name'];
}
$db->sql_freeresult($result);
@@ -494,6 +495,10 @@ class acp_attachments
$sql = 'SELECT group_id
FROM ' . EXTENSION_GROUPS_TABLE . "
WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($new_group_name)) . "'";
+ if ($group_id)
+ {
+ $sql .= ' AND group_id <> ' . $group_id;
+ }
$result = $db->sql_query($sql);
if ($db->sql_fetchrow($result))
@@ -551,6 +556,7 @@ class acp_attachments
$group_id = $db->sql_nextid();
}
+ $group_name = (isset($user->lang['EXT_GROUP_' . $group_name])) ? $user->lang['EXT_GROUP_' . $group_name] : $group_name;
add_log('admin', 'LOG_ATTACH_EXTGROUP_' . strtoupper($action), $group_name);
}
@@ -858,7 +864,7 @@ class acp_attachments
'U_EDIT' => $this->u_action . "&amp;action=edit&amp;g={$row['group_id']}",
'U_DELETE' => $this->u_action . "&amp;action=delete&amp;g={$row['group_id']}",
- 'GROUP_NAME' => $row['group_name'],
+ 'GROUP_NAME' => (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'],
'CATEGORY' => $cat_lang[$row['cat_id']],
)
);
@@ -1118,6 +1124,7 @@ class acp_attachments
$group_name = array();
while ($row = $db->sql_fetchrow($result))
{
+ $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'];
$group_name[] = $row;
}
$db->sql_freeresult($result);
@@ -1215,7 +1222,7 @@ class acp_attachments
return;
}
- if (!is_writable($phpbb_root_path . $upload_dir))
+ if (!phpbb_is_writable($phpbb_root_path . $upload_dir))
{
$error[] = sprintf($user->lang['NO_WRITE_UPLOAD'], $upload_dir);
return;
diff --git a/phpBB/includes/acp/acp_ban.php b/phpBB/includes/acp/acp_ban.php
index 3198376584..a7ea57b753 100644
--- a/phpBB/includes/acp/acp_ban.php
+++ b/phpBB/includes/acp/acp_ban.php
@@ -224,7 +224,7 @@ class acp_ban
$template->assign_block_vars('ban_reason', array(
'BAN_ID' => $ban_id,
'REASON' => $reason,
- 'A_REASON' => addslashes(htmlspecialchars_decode($reason)),
+ 'A_REASON' => addslashes($reason),
));
}
}
@@ -236,7 +236,7 @@ class acp_ban
$template->assign_block_vars('ban_give_reason', array(
'BAN_ID' => $ban_id,
'REASON' => $reason,
- 'A_REASON' => addslashes(htmlspecialchars_decode($reason)),
+ 'A_REASON' => addslashes($reason),
));
}
}
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index a5feac1902..a5e80e1f6d 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -58,7 +58,7 @@ class acp_board
'board_disable_msg' => false,
'default_lang' => array('lang' => 'DEFAULT_LANGUAGE', 'validate' => 'lang', 'type' => 'select', 'function' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false),
'default_dateformat' => array('lang' => 'DEFAULT_DATE_FORMAT', 'validate' => 'string', 'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true),
- 'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'string', 'type' => 'select', 'function' => 'tz_select', 'params' => array('{CONFIG_VALUE}', 1), 'explain' => false),
+ 'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'string', 'type' => 'select', 'function' => 'tz_select', 'params' => array('{CONFIG_VALUE}', 1), 'explain' => true),
'board_dst' => array('lang' => 'SYSTEM_DST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'default_style' => array('lang' => 'DEFAULT_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => false),
'override_user_style' => array('lang' => 'OVERRIDE_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
@@ -319,6 +319,7 @@ class acp_board
'load_online_guests' => array('lang' => 'YES_ONLINE_GUESTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'load_onlinetrack' => array('lang' => 'YES_ONLINE_TRACK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'load_birthdays' => array('lang' => 'YES_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'load_unreads_search' => array('lang' => 'YES_UNREAD_SEARCH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'load_moderators' => array('lang' => 'YES_MODERATORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'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),
@@ -888,8 +889,8 @@ class acp_board
$old_tz = $user->timezone;
$old_dst = $user->dst;
- $user->timezone = $config['board_timezone'];
- $user->dst = $config['board_dst'];
+ $user->timezone = $config['board_timezone'] * 3600;
+ $user->dst = $config['board_dst'] * 3600;
$dateformat_options = '';
diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php
index 56a57e319c..1893eed14f 100644
--- a/phpBB/includes/acp/acp_captcha.php
+++ b/phpBB/includes/acp/acp_captcha.php
@@ -89,14 +89,14 @@ class acp_captcha
}
else
{
- trigger_error($user->lang['CAPTCHA_UNAVAILABLE'] . adm_back_link($this->u_action));
+ trigger_error($user->lang['CAPTCHA_UNAVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
}
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
else if ($submit)
{
- trigger_error($user->lang['FORM_INVALID'] . adm_back_link());
+ trigger_error($user->lang['FORM_INVALID'] . adm_back_link(), E_USER_WARNING);
}
else
{
diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php
index abfad2b90b..193dd001c0 100644
--- a/phpBB/includes/acp/acp_database.php
+++ b/phpBB/includes/acp/acp_database.php
@@ -394,6 +394,7 @@ class acp_database
case 'mssql':
case 'mssql_odbc':
+ case 'mssqlnative':
while (($sql = $fgetd($fp, "GO\n", $read, $seek, $eof)) !== false)
{
$db->sql_query($sql);
@@ -1618,41 +1619,48 @@ class mssql_extractor extends base_extractor
function write_data_mssqlnative($table_name)
{
global $db;
- $ary_type = $ary_name = $meta_array = array();
+ $ary_type = $ary_name = array();
$ident_set = false;
$sql_data = '';
// Grab all of the data from current table.
$sql = "SELECT * FROM $table_name";
+ $db->mssqlnative_set_query_options(array('Scrollable' => SQLSRV_CURSOR_STATIC));
$result = $db->sql_query($sql);
- $retrieved_data = $db->mssqlnative_num_rows($result);
+ $retrieved_data = $db->mssqlnative_num_rows($result);
- $meta_array = sqlsrv_field_metadata($result);
- $i_num_fields = sqlsrv_num_fields($result);
-
+ if (!$retrieved_data)
+ {
+ $db->sql_freeresult($result);
+ return;
+ }
+
+ $sql = "SELECT * FROM $table_name";
+ $result_fields = $db->sql_query_limit($sql, 1);
+
+ $row = new result_mssqlnative($result_fields);
+ $i_num_fields = $row->num_fields();
+
for ($i = 0; $i < $i_num_fields; $i++)
{
- $info = $db->mssqlnative_fieldInfo($table_name, $meta_array[$i]['Name']);
- $ary_type[$i] = $info->type();
- $ary_name[$i] = $info->name();
+ $ary_type[$i] = $row->field_type($i);
+ $ary_name[$i] = $row->field_name($i);
}
+ $db->sql_freeresult($result_fields);
+
+ $sql = "SELECT 1 as has_identity
+ FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE COLUMNPROPERTY(object_id('$table_name'), COLUMN_NAME, 'IsIdentity') = 1";
+ $result2 = $db->sql_query($sql);
+ $row2 = $db->sql_fetchrow($result2);
- if ($retrieved_data)
+ if (!empty($row2['has_identity']))
{
- $sql = "SELECT 1 as has_identity
- FROM INFORMATION_SCHEMA.COLUMNS
- WHERE COLUMNPROPERTY(object_id('$table_name'), COLUMN_NAME, 'IsIdentity') = 1";
- $result2 = $db->sql_query($sql);
- $row2 = $db->sql_fetchrow($result2);
-
- if (!empty($row2['has_identity']))
- {
- $sql_data .= "\nSET IDENTITY_INSERT $table_name ON\nGO\n";
- $ident_set = true;
- }
- $db->sql_freeresult($result2);
+ $sql_data .= "\nSET IDENTITY_INSERT $table_name ON\nGO\n";
+ $ident_set = true;
}
+ $db->sql_freeresult($result2);
while ($row = $db->sql_fetchrow($result))
{
@@ -1663,7 +1671,8 @@ class mssql_extractor extends base_extractor
{
$str_val = $row[$ary_name[$i]];
- if (preg_match('#char|text|bool|varbinary#i', $ary_type[$i]))
+ // defaults to type number - better quote just to be safe, so check for is_int too
+ if (is_int($ary_type[$i]) || preg_match('#char|text|bool|varbinary#i', $ary_type[$i]))
{
$str_quote = '';
$str_empty = "''";
@@ -1704,7 +1713,7 @@ class mssql_extractor extends base_extractor
}
$db->sql_freeresult($result);
- if ($retrieved_data && $ident_set)
+ if ($ident_set)
{
$sql_data .= "\nSET IDENTITY_INSERT $table_name OFF\nGO\n";
}
diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php
index 5a5adc57ae..4d9b9f01e0 100644
--- a/phpBB/includes/acp/acp_forums.php
+++ b/phpBB/includes/acp/acp_forums.php
@@ -169,7 +169,7 @@ class acp_forums
$forum_data['forum_status'] = ITEM_UNLOCKED;
}
- $forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', true) : request_var('display_active', true);
+ $forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', true) : request_var('display_active', false);
// Get data for forum rules if specified...
if ($forum_data['forum_rules'])
@@ -190,12 +190,14 @@ class acp_forums
$forum_perm_from = request_var('forum_perm_from', 0);
$cache->destroy('sql', FORUMS_TABLE);
+ $copied_permissions = false;
// Copy permissions?
if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id'] &&
($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))))
{
copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false);
cache_moderators();
+ $copied_permissions = true;
}
/* Commented out because of questionable UI workflow - re-visit for 3.0.7
else if (!$this->parent_id && $action != 'edit' && $auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))
@@ -211,13 +213,13 @@ class acp_forums
$message = ($action == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED'];
// Redirect to permissions
- if ($auth->acl_get('a_fauth'))
+ if ($auth->acl_get('a_fauth') && !$copied_permissions)
{
$message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');
}
// redirect directly to permission settings screen if authed
- if ($action == 'add' && !$forum_perm_from && $auth->acl_get('a_fauth'))
+ if ($action == 'add' && !$copied_permissions && $auth->acl_get('a_fauth'))
{
meta_refresh(4, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url));
}
@@ -407,7 +409,7 @@ class acp_forums
$exclude_forums[] = $row['forum_id'];
}
- $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, true, false, false);
+ $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false);
$forum_data['forum_password_confirm'] = $forum_data['forum_password'];
}
@@ -416,7 +418,7 @@ class acp_forums
$this->page_title = 'CREATE_FORUM';
$forum_id = $this->parent_id;
- $parents_list = make_forum_select($this->parent_id, false, true, false, false);
+ $parents_list = make_forum_select($this->parent_id, false, false, false, false);
// Fill forum data with default values
if (!$update)
@@ -639,7 +641,8 @@ class acp_forums
'S_PRUNE_OLD_POLLS' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_POLL) ? true : false,
'S_PRUNE_ANNOUNCE' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_ANNOUNCE) ? true : false,
'S_PRUNE_STICKY' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_STICKY) ? true : false,
- 'S_DISPLAY_ACTIVE_TOPICS' => ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) ? true : false,
+ 'S_DISPLAY_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_POST) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : true,
+ 'S_ENABLE_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_CAT) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : false,
'S_ENABLE_POST_REVIEW' => ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false,
'S_ENABLE_QUICK_REPLY' => ($forum_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) ? true : false,
'S_CAN_COPY_PERMISSIONS' => ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))) ? true : false,
@@ -980,7 +983,7 @@ class acp_forums
if (!$row)
{
- trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&amp;' . $this->parent_id), E_USER_WARNING);
+ trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
}
if ($row['forum_type'] == FORUM_LINK)
@@ -1639,6 +1642,9 @@ class acp_forums
delete_attachments('topic', $topic_ids, false);
+ // Delete shadow topics pointing to topics in this forum
+ delete_topic_shadows($forum_id);
+
// Before we remove anything we make sure we are able to adjust the post counts later. ;)
$sql = 'SELECT poster_id
FROM ' . POSTS_TABLE . '
@@ -1705,6 +1711,9 @@ class acp_forums
)
);
+ // Amount of rows we select and delete in one iteration.
+ $batch_size = 500;
+
foreach ($tables_ary as $field => $tables)
{
$start = 0;
@@ -1714,7 +1723,7 @@ class acp_forums
$sql = "SELECT $field
FROM " . POSTS_TABLE . '
WHERE forum_id = ' . $forum_id;
- $result = $db->sql_query_limit($sql, 500, $start);
+ $result = $db->sql_query_limit($sql, $batch_size, $start);
$ids = array();
while ($row = $db->sql_fetchrow($result))
@@ -1733,7 +1742,7 @@ class acp_forums
}
}
}
- while ($row);
+ while (sizeof($ids) == $batch_size);
}
unset($ids);
diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php
index 3df61ff4e2..486616c33d 100644
--- a/phpBB/includes/acp/acp_groups.php
+++ b/phpBB/includes/acp/acp_groups.php
@@ -49,7 +49,7 @@ class acp_groups
// Clear some vars
- $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false;
+ $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false;
$group_row = array();
// Grab basic data for group, if group_id is set and exists
@@ -394,6 +394,15 @@ class acp_groups
}
}
+ // Validate the length of "Maximum number of allowed recipients per private message" setting.
+ // We use 16777215 as a maximum because it matches MySQL unsigned mediumint maximum value
+ // which is the lowest amongst DBMSes supported by phpBB3
+ if ($max_recipients_error = validate_data($submit_ary, array('max_recipients' => array('num', false, 0, 16777215))))
+ {
+ // Replace "error" string with its real, localised form
+ $error = array_merge($error, array_map(array(&$user, 'lang'), $max_recipients_error));
+ }
+
if (!sizeof($error))
{
// Only set the rank, colour, etc. if it's changed or if we're adding a new
diff --git a/phpBB/includes/acp/acp_php_info.php b/phpBB/includes/acp/acp_php_info.php
index 9935c0466e..0499095004 100644
--- a/phpBB/includes/acp/acp_php_info.php
+++ b/phpBB/includes/acp/acp_php_info.php
@@ -35,9 +35,9 @@ class acp_php_info
$this->tpl_name = 'acp_php_info';
$this->page_title = 'ACP_PHP_INFO';
-
+
ob_start();
- @phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES);
+ phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES);
$phpinfo = ob_get_clean();
$phpinfo = trim($phpinfo);
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php
index fc08c7e8e8..2288a0728b 100644
--- a/phpBB/includes/acp/acp_profile.php
+++ b/phpBB/includes/acp/acp_profile.php
@@ -1480,6 +1480,7 @@ class acp_profile
case 'mssql':
case 'mssql_odbc':
+ case 'mssqlnative':
// We are defining the biggest common value, because of the possibility to edit the min/max values of each field.
$sql = 'ALTER TABLE [' . PROFILE_FIELDS_DATA_TABLE . "] ADD [$field_ident] ";
diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php
index 7eeb37133f..ffe20f86f5 100644
--- a/phpBB/includes/acp/acp_prune.php
+++ b/phpBB/includes/acp/acp_prune.php
@@ -315,8 +315,8 @@ class acp_prune
'mode' => $mode,
'prune' => 1,
- 'users' => request_var('users', '', true),
- 'username' => request_var('username', '', true),
+ 'users' => utf8_normalize_nfc(request_var('users', '', true)),
+ 'username' => utf8_normalize_nfc(request_var('username', '', true)),
'email' => request_var('email', ''),
'joined_select' => request_var('joined_select', ''),
'joined' => request_var('joined', ''),
@@ -369,7 +369,7 @@ class acp_prune
{
global $user, $db;
- $users = request_var('users', '', true);
+ $users = utf8_normalize_nfc(request_var('users', '', true));
if ($users)
{
@@ -378,7 +378,7 @@ class acp_prune
}
else
{
- $username = request_var('username', '', true);
+ $username = utf8_normalize_nfc(request_var('username', '', true));
$email = request_var('email', '');
$joined_select = request_var('joined_select', 'lt');
diff --git a/phpBB/includes/acp/acp_reasons.php b/phpBB/includes/acp/acp_reasons.php
index 8d7bc88769..dbc9fcb6cc 100644
--- a/phpBB/includes/acp/acp_reasons.php
+++ b/phpBB/includes/acp/acp_reasons.php
@@ -233,6 +233,7 @@ class acp_reasons
// Standard? What's that?
case 'mssql':
case 'mssql_odbc':
+ case 'mssqlnative':
// Change the reports using this reason to 'other'
$sql = "DECLARE @ptrval binary(16)
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index 3310560c73..2ccc728031 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -748,7 +748,7 @@ parse_css_file = {PARSE_CSS_FILE}
$additional = '';
// If the template is stored on the filesystem try to write the file else store it in the database
- if (!$safe_mode && !$template_info['template_storedb'] && file_exists($file) && @is_writable($file))
+ if (!$safe_mode && !$template_info['template_storedb'] && file_exists($file) && phpbb_is_writable($file))
{
if (!($fp = @fopen($file, 'wb')))
{
@@ -1155,7 +1155,7 @@ parse_css_file = {PARSE_CSS_FILE}
$message = $user->lang['THEME_UPDATED'];
// If the theme is stored on the filesystem try to write the file else store it in the database
- if (!$safe_mode && !$theme_info['theme_storedb'] && file_exists($file) && @is_writable($file))
+ if (!$safe_mode && !$theme_info['theme_storedb'] && file_exists($file) && phpbb_is_writable($file))
{
if (!($fp = @fopen($file, 'wb')))
{
@@ -2040,23 +2040,18 @@ parse_css_file = {PARSE_CSS_FILE}
{
case 'tar':
$ext = '.tar';
- $mimetype = 'x-tar';
- $compress = 'compress_tar';
break;
case 'zip':
$ext = '.zip';
- $mimetype = 'zip';
break;
case 'tar.gz':
$ext = '.tar.gz';
- $mimetype = 'x-gzip';
break;
case 'tar.bz2':
$ext = '.tar.bz2';
- $mimetype = 'x-bzip2';
break;
default:
@@ -2246,7 +2241,7 @@ parse_css_file = {PARSE_CSS_FILE}
{
// a rather elaborate check we have to do here once to avoid trouble later
$check = "{$phpbb_root_path}styles/" . $style_row["{$mode}_path"] . (($mode === 'theme') ? '/theme/stylesheet.css' : '/template');
- if (($style_row["{$mode}_storedb"] != $store_db) && !$store_db && ($safe_mode || !@is_writable($check)))
+ if (($style_row["{$mode}_storedb"] != $store_db) && !$store_db && ($safe_mode || !phpbb_is_writable($check)))
{
$error[] = $user->lang['EDIT_' . strtoupper($mode) . '_STORED_DB'];
$store_db = 1;
@@ -2326,7 +2321,7 @@ parse_css_file = {PARSE_CSS_FILE}
{
$theme_data = $this->db_theme_data($style_row);
}
- else if (!$store_db && !$safe_mode && @is_writable("{$phpbb_root_path}styles/{$style_row['theme_path']}/theme/stylesheet.css"))
+ else if (!$store_db && !$safe_mode && phpbb_is_writable("{$phpbb_root_path}styles/{$style_row['theme_path']}/theme/stylesheet.css"))
{
$store_db = 1;
$theme_data = $style_row['theme_data'];
@@ -2357,7 +2352,7 @@ parse_css_file = {PARSE_CSS_FILE}
}
else
{
- if (!$store_db && !$safe_mode && @is_writable("{$phpbb_root_path}styles/{$style_row['template_path']}/template"))
+ if (!$store_db && !$safe_mode && phpbb_is_writable("{$phpbb_root_path}styles/{$style_row['template_path']}/template"))
{
$err = $this->store_in_fs('template', $style_row['template_id']);
if ($err)
@@ -2531,13 +2526,21 @@ parse_css_file = {PARSE_CSS_FILE}
// Match CSS imports
$matches = array();
- preg_match_all('/@import url\(["\'](.*)["\']\);/i', $stylesheet, $matches);
+ preg_match_all('/@import url\((["\'])(.*)\1\);/i', $stylesheet, $matches);
+
+ // remove commented stylesheets (very simple parser, allows only whitespace
+ // around an @import statement)
+ preg_match_all('#/\*\s*@import url\((["\'])(.*)\1\);\s\*/#i', $stylesheet, $commented);
+ $matches[2] = array_diff($matches[2], $commented[2]);
if (sizeof($matches))
{
foreach ($matches[0] as $idx => $match)
{
- $stylesheet = str_replace($match, acp_styles::load_css_file($theme_row['theme_path'], $matches[1][$idx]), $stylesheet);
+ if (isset($matches[2][$idx]))
+ {
+ $stylesheet = str_replace($match, acp_styles::load_css_file($theme_row['theme_path'], $matches[2][$idx]), $stylesheet);
+ }
}
}
@@ -3728,7 +3731,7 @@ parse_css_file = {PARSE_CSS_FILE}
$store_db = 0;
$error = array();
- if (!$safe_mode && @is_writable("{$phpbb_root_path}styles/{$path}/template"))
+ if (!$safe_mode && phpbb_is_writable("{$phpbb_root_path}styles/{$path}/template"))
{
$sql = 'SELECT *
FROM ' . STYLES_TEMPLATE_DATA_TABLE . "
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index 4905840e02..6be0760be0 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -105,7 +105,7 @@ class acp_users
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id)
WHERE u.user_id = ' . $user_id . '
ORDER BY s.session_time DESC';
- $result = $db->sql_query($sql);
+ $result = $db->sql_query_limit($sql, 1);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -191,24 +191,31 @@ class acp_users
trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
- if (confirm_box(true))
+ if ($delete_type)
{
- user_delete($delete_type, $user_id, $user_row['username']);
+ if (confirm_box(true))
+ {
+ user_delete($delete_type, $user_id, $user_row['username']);
- add_log('admin', 'LOG_USER_DELETED', $user_row['username']);
- trigger_error($user->lang['USER_DELETED'] . adm_back_link($this->u_action));
+ add_log('admin', 'LOG_USER_DELETED', $user_row['username']);
+ trigger_error($user->lang['USER_DELETED'] . adm_back_link($this->u_action));
+ }
+ else
+ {
+ confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
+ 'u' => $user_id,
+ 'i' => $id,
+ 'mode' => $mode,
+ 'action' => $action,
+ 'update' => true,
+ 'delete' => 1,
+ 'delete_type' => $delete_type))
+ );
+ }
}
else
{
- confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
- 'u' => $user_id,
- 'i' => $id,
- 'mode' => $mode,
- 'action' => $action,
- 'update' => true,
- 'delete' => 1,
- 'delete_type' => $delete_type))
- );
+ trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
}
@@ -224,6 +231,11 @@ class acp_users
trigger_error($user->lang['CANNOT_BAN_YOURSELF'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
+ if ($user_id == ANONYMOUS)
+ {
+ trigger_error($user->lang['CANNOT_BAN_ANONYMOUS'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
+ }
+
if ($user_row['user_type'] == USER_FOUNDER)
{
trigger_error($user->lang['CANNOT_BAN_FOUNDER'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
@@ -307,10 +319,7 @@ class acp_users
$server_url = generate_board_url();
- $user_actkey = gen_rand_string(10);
- $key_len = 54 - (strlen($server_url));
- $key_len = ($key_len > 6) ? $key_len : 6;
- $user_actkey = substr($user_actkey, 0, $key_len);
+ $user_actkey = gen_rand_string(mt_rand(6, 10));
$email_template = ($user_row['user_type'] == USER_NORMAL) ? 'user_reactivate_account' : 'user_resend_inactive';
if ($user_row['user_type'] == USER_NORMAL)
@@ -1550,6 +1559,31 @@ class acp_users
WHERE user_id = $user_id";
$db->sql_query($sql);
+ // Check if user has an active session
+ if ($user_row['session_id'])
+ {
+ // We'll update the session if user_allow_viewonline has changed and the user is a bot
+ // Or if it's a regular user and the admin set it to hide the session
+ if ($user_row['user_allow_viewonline'] != $sql_ary['user_allow_viewonline'] && $user_row['user_type'] == USER_IGNORE
+ || $user_row['user_allow_viewonline'] && !$sql_ary['user_allow_viewonline'])
+ {
+ // We also need to check if the user has the permission to cloak.
+ $user_auth = new auth();
+ $user_auth->acl($user_row);
+
+ $session_sql_ary = array(
+ 'session_viewonline' => ($user_auth->acl_get('u_hideonline')) ? $sql_ary['user_allow_viewonline'] : true,
+ );
+
+ $sql = 'UPDATE ' . SESSIONS_TABLE . '
+ SET ' . $db->sql_build_array('UPDATE', $session_sql_ary) . "
+ WHERE session_user_id = $user_id";
+ $db->sql_query($sql);
+
+ unset($user_auth);
+ }
+ }
+
trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
}
@@ -1664,7 +1698,7 @@ class acp_users
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
- $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false;
+ $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false;
if ($submit)
{
@@ -1674,7 +1708,7 @@ class acp_users
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
- if (avatar_process_user($error, $user_row))
+ if (avatar_process_user($error, $user_row, $can_upload))
{
trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&amp;u=' . $user_row['user_id']));
}
@@ -2084,7 +2118,7 @@ class acp_users
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id)
WHERE u.user_id = ' . $user_id . '
ORDER BY s.session_time DESC';
- $result = $db->sql_query($sql);
+ $result = $db->sql_query_limit($sql, 1);
$user_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
diff --git a/phpBB/includes/acp/info/acp_board.php b/phpBB/includes/acp/info/acp_board.php
index 58b650650c..3e18f55940 100644
--- a/phpBB/includes/acp/info/acp_board.php
+++ b/phpBB/includes/acp/info/acp_board.php
@@ -24,7 +24,7 @@ class acp_board_info
'features' => array('title' => 'ACP_BOARD_FEATURES', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')),
'avatar' => array('title' => 'ACP_AVATAR_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')),
'message' => array('title' => 'ACP_MESSAGE_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION', 'ACP_MESSAGES')),
- 'post' => array('title' => 'ACP_POST_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')),
+ 'post' => array('title' => 'ACP_POST_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION', 'ACP_MESSAGES')),
'signature' => array('title' => 'ACP_SIGNATURE_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')),
'feed' => array('title' => 'ACP_FEED_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')),
'registration' => array('title' => 'ACP_REGISTER_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')),
diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php
index 73c4f92976..e04a6307e9 100644
--- a/phpBB/includes/auth/auth_db.php
+++ b/phpBB/includes/auth/auth_db.php
@@ -134,7 +134,8 @@ function login_db(&$username, &$password)
// increase login attempt count to make sure this cannot be exploited
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_login_attempts = user_login_attempts + 1
- WHERE user_id = ' . $row['user_id'];
+ WHERE user_id = ' . (int) $row['user_id'] . '
+ AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX;
$db->sql_query($sql);
return array(
@@ -194,7 +195,8 @@ function login_db(&$username, &$password)
// Password incorrect - increase login attempts
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_login_attempts = user_login_attempts + 1
- WHERE user_id = ' . $row['user_id'];
+ WHERE user_id = ' . (int) $row['user_id'] . '
+ AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX;
$db->sql_query($sql);
// Give status about wrong password...
diff --git a/phpBB/includes/auth/auth_ldap.php b/phpBB/includes/auth/auth_ldap.php
index a6092baba5..e8c957aaa3 100644
--- a/phpBB/includes/auth/auth_ldap.php
+++ b/phpBB/includes/auth/auth_ldap.php
@@ -74,7 +74,7 @@ function init_ldap()
if ($search === false)
{
- return $user->lang['LDAP_NO_SERVER_CONNECTION'];
+ return $user->lang['LDAP_SEARCH_FAILED'];
}
$result = @ldap_get_entries($ldap, $search);
diff --git a/phpBB/includes/cache.php b/phpBB/includes/cache.php
index 6b1e078ca4..b50fab4ca2 100644
--- a/phpBB/includes/cache.php
+++ b/phpBB/includes/cache.php
@@ -88,7 +88,14 @@ class cache extends acm
{
if ($unicode)
{
- $censors['match'][] = '#(?<![\p{Nd}\p{L}_])(' . str_replace('\*', '[\p{Nd}\p{L}_]*?', preg_quote($row['word'], '#')) . ')(?![\p{Nd}\p{L}_])#iu';
+ // Unescape the asterisk to simplify further conversions
+ $row['word'] = str_replace('\*', '*', preg_quote($row['word'], '#'));
+
+ // Replace the asterisk inside the pattern, at the start and at the end of it with regexes
+ $row['word'] = preg_replace(array('#(?<=[\p{Nd}\p{L}_])\*(?=[\p{Nd}\p{L}_])#iu', '#^\*#', '#\*$#'), array('([\x20]*?|[\p{Nd}\p{L}_-]*?)', '[\p{Nd}\p{L}_-]*?', '[\p{Nd}\p{L}_-]*?'), $row['word']);
+
+ // Generate the final substitution
+ $censors['match'][] = '#(?<![\p{Nd}\p{L}_-])(' . $row['word'] . ')(?![\p{Nd}\p{L}_-])#iu';
}
else
{
diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php
index e7b8742b05..21cacd730c 100644
--- a/phpBB/includes/captcha/plugins/captcha_abstract.php
+++ b/phpBB/includes/captcha/plugins/captcha_abstract.php
@@ -59,7 +59,7 @@ class phpbb_default_captcha
{
global $user;
- $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS));
+ $this->code = gen_rand_string_friendly(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS));
$this->seed = hexdec(substr(unique_id(), 4, 10));
// compute $seed % 0x7fffffff
@@ -235,7 +235,7 @@ class phpbb_default_captcha
{
global $db, $user;
- $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS));
+ $this->code = gen_rand_string_friendly(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS));
$this->confirm_id = md5(unique_id($user->ip));
$this->seed = hexdec(substr(unique_id(), 4, 10));
$this->solved = 0;
@@ -259,7 +259,7 @@ class phpbb_default_captcha
{
global $db, $user;
- $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS));
+ $this->code = gen_rand_string_friendly(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS));
$this->seed = hexdec(substr(unique_id(), 4, 10));
$this->solved = 0;
// compute $seed % 0x7fffffff
@@ -281,7 +281,7 @@ class phpbb_default_captcha
{
global $db, $user;
- $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS));
+ $this->code = gen_rand_string_friendly(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS));
$this->seed = hexdec(substr(unique_id(), 4, 10));
$this->solved = 0;
// compute $seed % 0x7fffffff
diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
index 0f0bfc4156..ea171dbe2c 100644
--- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
@@ -314,10 +314,7 @@ class phpbb_recaptcha extends phpbb_default_captcha
}
else
{
- if ($answers[1] === 'incorrect-captcha-sol')
- {
- return $user->lang['RECAPTCHA_INCORRECT'];
- }
+ return $user->lang['RECAPTCHA_INCORRECT'];
}
}
diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php
index 8d31eaba7f..ebaa342f54 100644
--- a/phpBB/includes/constants.php
+++ b/phpBB/includes/constants.php
@@ -69,6 +69,10 @@ define('LOGIN_ERROR_ATTEMPTS', 13);
define('LOGIN_ERROR_EXTERNAL_AUTH', 14);
define('LOGIN_ERROR_PASSWORD_CONVERT', 15);
+// Maximum login attempts
+// The value is arbitrary, but it has to fit into the user_login_attempts field.
+define('LOGIN_ATTEMPTS_MAX', 100);
+
// Group settings
define('GROUP_OPEN', 0);
define('GROUP_CLOSED', 1);
@@ -117,6 +121,10 @@ define('NOTIFY_EMAIL', 0);
define('NOTIFY_IM', 1);
define('NOTIFY_BOTH', 2);
+// Notify status
+define('NOTIFY_YES', 0);
+define('NOTIFY_NO', 1);
+
// Email Priority Settings
define('MAIL_LOW_PRIORITY', 4);
define('MAIL_NORMAL_PRIORITY', 3);
diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php
index 819ef69c96..f4b181c6ad 100644
--- a/phpBB/includes/db/db_tools.php
+++ b/phpBB/includes/db/db_tools.php
@@ -611,7 +611,7 @@ class phpbb_db_tools
* drop_columns: Removing/Dropping columns
* add_primary_keys: adding primary keys
* add_unique_index: adding an unique index
- * add_index: adding an index
+ * add_index: adding an index (can be column:index_size if you need to provide size)
*
* The values are in this format:
* {TABLE NAME} => array(
@@ -1804,6 +1804,12 @@ class phpbb_db_tools
{
$statements = array();
+ // remove index length unless MySQL4
+ if ('mysql_40' != $this->sql_layer)
+ {
+ $column = preg_replace('#:.*$#', '', $column);
+ }
+
switch ($this->sql_layer)
{
case 'firebird':
@@ -1814,6 +1820,16 @@ class phpbb_db_tools
break;
case 'mysql_40':
+ // add index size to definition as required by MySQL4
+ foreach ($column as $i => $col)
+ {
+ if (false !== strpos($col, ':'))
+ {
+ list($col, $index_size) = explode(':', $col);
+ $column[$i] = "$col($index_size)";
+ }
+ }
+ // no break
case 'mysql_41':
$statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')';
break;
diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php
index e554b0f2fb..6f60dd5dad 100644
--- a/phpBB/includes/db/firebird.php
+++ b/phpBB/includes/db/firebird.php
@@ -63,10 +63,19 @@ class dbal_firebird extends dbal
/**
* Version information about used database
* @param bool $raw if true, only return the fetched sql_server_version
+ * @param bool $use_cache forced to false for Interbase
* @return string sql server version
*/
- function sql_server_info($raw = false)
+ function sql_server_info($raw = false, $use_cache = true)
{
+ /**
+ * force $use_cache false. I didn't research why the caching code there is no caching code
+ * but I assume its because the IB extension provides a direct method to access it
+ * without a query.
+ */
+
+ $use_cache = false;
+
if ($this->service_handle !== false && function_exists('ibase_server_info'))
{
return @ibase_server_info($this->service_handle, IBASE_SVC_SERVER_VERSION);
diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php
index 7134574691..6899a73902 100644
--- a/phpBB/includes/db/mssql.php
+++ b/phpBB/includes/db/mssql.php
@@ -65,13 +65,14 @@ class dbal_mssql extends dbal
/**
* Version information about used database
* @param bool $raw if true, only return the fetched sql_server_version
+ * @param bool $use_cache If true, it is safe to retrieve the value from the cache
* @return string sql server version
*/
- function sql_server_info($raw = false)
+ function sql_server_info($raw = false, $use_cache = true)
{
global $cache;
- if (empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false)
+ if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false)
{
$result_id = @mssql_query("SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')", $this->db_connect_id);
@@ -84,7 +85,7 @@ class dbal_mssql extends dbal
$this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0;
- if (!empty($cache))
+ if (!empty($cache) && $use_cache)
{
$cache->put('mssql_version', $this->sql_server_version);
}
diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php
index 14c4831010..75a080b1b7 100644
--- a/phpBB/includes/db/mssql_odbc.php
+++ b/phpBB/includes/db/mssql_odbc.php
@@ -76,13 +76,14 @@ class dbal_mssql_odbc extends dbal
/**
* Version information about used database
* @param bool $raw if true, only return the fetched sql_server_version
+ * @param bool $use_cache If true, it is safe to retrieve the value from the cache
* @return string sql server version
*/
- function sql_server_info($raw = false)
+ function sql_server_info($raw = false, $use_cache = true)
{
global $cache;
- if (empty($cache) || ($this->sql_server_version = $cache->get('mssqlodbc_version')) === false)
+ if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssqlodbc_version')) === false)
{
$result_id = @odbc_exec($this->db_connect_id, "SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')");
@@ -95,7 +96,7 @@ class dbal_mssql_odbc extends dbal
$this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0;
- if (!empty($cache))
+ if (!empty($cache) && $use_cache)
{
$cache->put('mssqlodbc_version', $this->sql_server_version);
}
diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php
index 08ee70907c..d6ac3b3acc 100644
--- a/phpBB/includes/db/mssqlnative.php
+++ b/phpBB/includes/db/mssqlnative.php
@@ -51,7 +51,6 @@ class result_mssqlnative
}
$this->m_row_count = count($this->m_rows);
- sqlsrv_free_stmt($queryresult);
}
private function array_to_obj($array, &$obj)
@@ -199,6 +198,7 @@ class dbal_mssqlnative extends dbal
{
var $m_insert_id = NULL;
var $last_query_text = '';
+ var $query_options = array();
/**
* Connect to server
@@ -232,18 +232,19 @@ class dbal_mssqlnative extends dbal
/**
* Version information about used database
* @param bool $raw if true, only return the fetched sql_server_version
+ * @param bool $use_cache If true, it is safe to retrieve the value from the cache
* @return string sql server version
*/
- function sql_server_info($raw = false)
+ function sql_server_info($raw = false, $use_cache = true)
{
global $cache;
- if (empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false)
+ if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false)
{
$arr_server_info = sqlsrv_server_info($this->db_connect_id);
$this->sql_server_version = $arr_server_info['SQLServerVersion'];
- if (!empty($cache))
+ if (!empty($cache) && $use_cache)
{
$cache->put('mssql_version', $this->sql_server_version);
}
@@ -307,10 +308,12 @@ class dbal_mssqlnative extends dbal
if ($this->query_result === false)
{
- if (($this->query_result = @sqlsrv_query($this->db_connect_id, $query)) === false)
+ if (($this->query_result = @sqlsrv_query($this->db_connect_id, $query, array(), $this->query_options)) === false)
{
$this->sql_error($query);
}
+ // reset options for next query
+ $this->query_options = array();
if (defined('DEBUG_EXTRA'))
{
@@ -502,6 +505,7 @@ class dbal_mssqlnative extends dbal
{
$errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS);
$error_message = '';
+ $code = 0;
if ($errors != null)
{
@@ -509,6 +513,7 @@ class dbal_mssqlnative extends dbal
{
$error_message .= "SQLSTATE: ".$error[ 'SQLSTATE']."\n";
$error_message .= "code: ".$error[ 'code']."\n";
+ $code = $error['code'];
$error_message .= "message: ".$error[ 'message']."\n";
}
$this->last_error_result = $error_message;
@@ -518,7 +523,11 @@ class dbal_mssqlnative extends dbal
{
$error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();
}
- return $error;
+
+ return array(
+ 'message' => $error,
+ 'code' => $code,
+ );
}
/**
@@ -591,20 +600,28 @@ class dbal_mssqlnative extends dbal
* Utility method used to retrieve number of rows
* Emulates mysql_num_rows
* Used in acp_database.php -> write_data_mssqlnative()
+ * Requires a static or keyset cursor to be definde via
+ * mssqlnative_set_query_options()
*/
function mssqlnative_num_rows($res)
{
if ($res !== false)
{
- $row = new result_mssqlnative($res);
- $num_rows = $row->num_rows();
- return $num_rows;
+ return sqlsrv_num_rows($res);
}
else
{
return false;
}
}
+
+ /**
+ * Allows setting mssqlnative specific query options passed to sqlsrv_query as 4th parameter.
+ */
+ function mssqlnative_set_query_options($options)
+ {
+ $this->query_options = $options;
+ }
}
?> \ No newline at end of file
diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php
index 0487dfa6d2..1e24c79577 100644
--- a/phpBB/includes/db/mysql.php
+++ b/phpBB/includes/db/mysql.php
@@ -96,13 +96,14 @@ class dbal_mysql extends dbal
/**
* Version information about used database
* @param bool $raw if true, only return the fetched sql_server_version
+ * @param bool $use_cache If true, it is safe to retrieve the value from the cache
* @return string sql server version
*/
- function sql_server_info($raw = false)
+ function sql_server_info($raw = false, $use_cache = true)
{
global $cache;
- if (empty($cache) || ($this->sql_server_version = $cache->get('mysql_version')) === false)
+ if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysql_version')) === false)
{
$result = @mysql_query('SELECT VERSION() AS version', $this->db_connect_id);
$row = @mysql_fetch_assoc($result);
@@ -110,7 +111,7 @@ class dbal_mysql extends dbal
$this->sql_server_version = $row['version'];
- if (!empty($cache))
+ if (!empty($cache) && $use_cache)
{
$cache->put('mysql_version', $this->sql_server_version);
}
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index f0e58fd148..862d62f4ba 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -80,14 +80,14 @@ class dbal_mysqli extends dbal
/**
* Version information about used database
- * @param bool $raw if true, only return the fetched sql_server_version
+ * @param bool $use_cache If true, it is safe to retrieve the value from the cache
* @return string sql server version
*/
- function sql_server_info($raw = false)
+ function sql_server_info($raw = false, $use_cache = true)
{
global $cache;
- if (empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false)
+ if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false)
{
$result = @mysqli_query($this->db_connect_id, 'SELECT VERSION() AS version');
$row = @mysqli_fetch_assoc($result);
@@ -95,7 +95,7 @@ class dbal_mysqli extends dbal
$this->sql_server_version = $row['version'];
- if (!empty($cache))
+ if (!empty($cache) && $use_cache)
{
$cache->put('mysqli_version', $this->sql_server_version);
}
diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php
index 55b3599800..c8a9a5f604 100644
--- a/phpBB/includes/db/oracle.php
+++ b/phpBB/includes/db/oracle.php
@@ -56,10 +56,18 @@ class dbal_oracle extends dbal
/**
* Version information about used database
* @param bool $raw if true, only return the fetched sql_server_version
+ * @param bool $use_cache forced to false for Oracle
* @return string sql server version
*/
- function sql_server_info($raw = false)
+ function sql_server_info($raw = false, $use_cache = true)
{
+ /**
+ * force $use_cache false. I didn't research why the caching code below is commented out
+ * but I assume its because the Oracle extension provides a direct method to access it
+ * without a query.
+ */
+
+ $use_cache = false;
/*
global $cache;
@@ -261,6 +269,10 @@ class dbal_oracle extends dbal
{
$cols = explode(', ', $regs[2]);
+/* The code inside this comment block breaks clob handling, but does allow the
+ database restore script to work. If you want to allow no posts longer than 4KB
+ and/or need the db restore script, uncomment this.
+
preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER);
if (sizeof($cols) !== sizeof($vals))
@@ -310,6 +322,7 @@ class dbal_oracle extends dbal
$vals = array(0 => $vals);
}
+*/
$inserts = $vals[0];
unset($vals);
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php
index d117e8c948..4360c790a1 100644
--- a/phpBB/includes/db/postgres.php
+++ b/phpBB/includes/db/postgres.php
@@ -46,7 +46,10 @@ class dbal_postgres extends dbal
if ($sqlserver)
{
- if (strpos($sqlserver, ':') !== false)
+ // $sqlserver can carry a port separated by : for compatibility reasons
+ // If $sqlserver has more than one : it's probably an IPv6 address.
+ // In this case we only allow passing a port via the $port variable.
+ if (substr_count($sqlserver, ':') === 1)
{
list($sqlserver, $port) = explode(':', $sqlserver);
}
@@ -76,7 +79,14 @@ class dbal_postgres extends dbal
$this->persistency = $persistency;
- $this->db_connect_id = ($this->persistency) ? @pg_pconnect($connect_string, $new_link) : @pg_connect($connect_string, $new_link);
+ if ($this->persistency)
+ {
+ $this->db_connect_id = (!$new_link) ? @pg_pconnect($connect_string) : @pg_pconnect($connect_string, PGSQL_CONNECT_FORCE_NEW);
+ }
+ else
+ {
+ $this->db_connect_id = (!$new_link) ? @pg_connect($connect_string) : @pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW);
+ }
if ($this->db_connect_id)
{
@@ -98,13 +108,14 @@ class dbal_postgres extends dbal
/**
* Version information about used database
* @param bool $raw if true, only return the fetched sql_server_version
+ * @param bool $use_cache If true, it is safe to retrieve the value from the cache
* @return string sql server version
*/
- function sql_server_info($raw = false)
+ function sql_server_info($raw = false, $use_cache = true)
{
global $cache;
- if (empty($cache) || ($this->sql_server_version = $cache->get('pgsql_version')) === false)
+ if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('pgsql_version')) === false)
{
$query_id = @pg_query($this->db_connect_id, 'SELECT VERSION() AS version');
$row = @pg_fetch_assoc($query_id, null);
@@ -112,7 +123,7 @@ class dbal_postgres extends dbal
$this->sql_server_version = (!empty($row['version'])) ? trim(substr($row['version'], 10)) : 0;
- if (!empty($cache))
+ if (!empty($cache) && $use_cache)
{
$cache->put('pgsql_version', $this->sql_server_version);
}
diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php
index 288f6e0992..8de72fd394 100644
--- a/phpBB/includes/db/sqlite.php
+++ b/phpBB/includes/db/sqlite.php
@@ -50,19 +50,24 @@ class dbal_sqlite extends dbal
/**
* Version information about used database
* @param bool $raw if true, only return the fetched sql_server_version
+ * @param bool $use_cache if true, it is safe to retrieve the stored value from the cache
* @return string sql server version
*/
- function sql_server_info($raw = false)
+ function sql_server_info($raw = false, $use_cache = true)
{
global $cache;
- if (empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false)
+ if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false)
{
$result = @sqlite_query('SELECT sqlite_version() AS version', $this->db_connect_id);
$row = @sqlite_fetch_array($result, SQLITE_ASSOC);
$this->sql_server_version = (!empty($row['version'])) ? $row['version'] : 0;
- $cache->put('sqlite_version', $this->sql_server_version);
+
+ if (!empty($cache) && $use_cache)
+ {
+ $cache->put('sqlite_version', $this->sql_server_version);
+ }
}
return ($raw) ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version;
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 4f52c7c2ce..e154aa44b0 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -175,11 +175,8 @@ function set_config_count($config_name, $increment, $is_dynamic = false)
switch ($db->sql_layer)
{
case 'firebird':
- $sql_update = 'CAST(CAST(config_value as integer) + ' . (int) $increment . ' as VARCHAR(255))';
- break;
-
case 'postgres':
- $sql_update = 'int4(config_value) + ' . (int) $increment;
+ $sql_update = 'CAST(CAST(config_value as DECIMAL(255, 0)) + ' . (int) $increment . ' as VARCHAR(255))';
break;
// MySQL, SQlite, mssql, mssql_odbc, oracle
@@ -198,10 +195,27 @@ function set_config_count($config_name, $increment, $is_dynamic = false)
/**
* Generates an alphanumeric random string of given length
+*
+* @return string
*/
function gen_rand_string($num_chars = 8)
{
+ // [a, z] + [0, 9] = 36
+ return substr(strtoupper(base_convert(unique_id(), 16, 36)), 0, $num_chars);
+}
+
+/**
+* Generates a user-friendly alphanumeric random string of given length
+* We remove 0 and O so users cannot confuse those in passwords etc.
+*
+* @return string
+*/
+function gen_rand_string_friendly($num_chars = 8)
+{
$rand_str = unique_id();
+
+ // Remove Z and Y from the base_convert(), replace 0 with Z and O with Y
+ // [a, z] + [0, 9] - {z, y} = [a, z] + [0, 9] - {0, o} = 34
$rand_str = str_replace(array('0', 'O'), array('Z', 'Y'), strtoupper(base_convert($rand_str, 16, 34)));
return substr($rand_str, 0, $num_chars);
@@ -704,7 +718,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ)
clearstatcache();
- if (is_readable($filename) && is_writable($filename))
+ if (is_readable($filename) && phpbb_is_writable($filename))
{
break;
}
@@ -714,7 +728,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ)
clearstatcache();
- if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename)))
+ if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || phpbb_is_writable($filename)))
{
break;
}
@@ -724,7 +738,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ)
clearstatcache();
- if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename)))
+ if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || phpbb_is_writable($filename)))
{
break;
}
@@ -1663,10 +1677,11 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
* @param string $sql_extra Extra WHERE SQL statement
* @param string $sql_sort ORDER BY SQL sorting statement
* @param string $sql_limit Limits the size of unread topics list, 0 for unlimited query
+* @param string $sql_limit_offset Sets the offset of the first row to search, 0 to search from the start
*
* @return array[int][int] Topic ids as keys, mark_time of topic as value
*/
-function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001)
+function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001, $sql_limit_offset = 0)
{
global $config, $db, $user;
@@ -1712,7 +1727,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s
);
$sql = $db->sql_build_query('SELECT', $sql_array);
- $result = $db->sql_query_limit($sql, $sql_limit);
+ $result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset);
while ($row = $db->sql_fetchrow($result))
{
@@ -1745,7 +1760,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s
WHERE t.topic_last_post_time > ' . $user_lastmark . "
$sql_extra
$sql_sort";
- $result = $db->sql_query_limit($sql, $sql_limit);
+ $result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset);
while ($row = $db->sql_fetchrow($result))
{
@@ -2521,6 +2536,11 @@ function build_url($strip_vars = false)
$key = $arguments[0];
unset($arguments[0]);
+ if ($key === '')
+ {
+ continue;
+ }
+
$query[$key] = implode('=', $arguments);
}
@@ -2581,6 +2601,47 @@ function meta_refresh($time, $url, $disable_cd_check = false)
return $url;
}
+/**
+* Outputs correct status line header.
+*
+* Depending on php sapi one of the two following forms is used:
+*
+* Status: 404 Not Found
+*
+* HTTP/1.x 404 Not Found
+*
+* HTTP version is taken from HTTP_VERSION environment variable,
+* and defaults to 1.0.
+*
+* Sample usage:
+*
+* send_status_line(404, 'Not Found');
+*
+* @param int $code HTTP status code
+* @param string $message Message for the status code
+* @return void
+*/
+function send_status_line($code, $message)
+{
+ if (substr(strtolower(@php_sapi_name()), 0, 3) === 'cgi')
+ {
+ // in theory, we shouldn't need that due to php doing it. Reality offers a differing opinion, though
+ header("Status: $code $message", true, $code);
+ }
+ else
+ {
+ if (isset($_SERVER['HTTP_VERSION']))
+ {
+ $version = $_SERVER['HTTP_VERSION'];
+ }
+ else
+ {
+ $version = 'HTTP/1.0';
+ }
+ header("$version $code $message", true, $code);
+ }
+}
+
//Form validation
@@ -3316,7 +3377,9 @@ function get_preg_expression($mode)
switch ($mode)
{
case 'email':
- return '(?:[a-z0-9\'\.\-_\+\|]++|&amp;)+@[a-z0-9\-]+\.(?:[a-z0-9\-]+\.)*[a-z]+';
+ // Regex written by James Watts and Francisco Jose Martin Moreno
+ // http://fightingforalostcause.net/misc/2006/compare-email-regex.php
+ return '([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*(?:[\w\!\#$\%\'\*\+\-\/\=\?\^\`{\|\}\~]|&amp;)+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)';
break;
case 'bbcode_htm':
@@ -3338,7 +3401,7 @@ function get_preg_expression($mode)
break;
case 'ipv6':
- return '#^(?:(?:(?:[\dA-F]{1,4}:){6}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:::(?:[\dA-F]{1,4}:){5}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:):(?:[\dA-F]{1,4}:){4}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,2}:(?:[\dA-F]{1,4}:){3}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,3}:(?:[\dA-F]{1,4}:){2}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,4}:(?:[\dA-F]{1,4}:)(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,5}:(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,6}:[\dA-F]{1,4})|(?:(?:[\dA-F]{1,4}:){1,7}:))$#i';
+ return '#^(?:(?:(?:[\dA-F]{1,4}:){6}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:::(?:[\dA-F]{1,4}:){0,5}(?:[\dA-F]{1,4}(?::[\dA-F]{1,4})?|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:):(?:[\dA-F]{1,4}:){4}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,2}:(?:[\dA-F]{1,4}:){3}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,3}:(?:[\dA-F]{1,4}:){2}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,4}:(?:[\dA-F]{1,4}:)(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,5}:(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,6}:[\dA-F]{1,4})|(?:(?:[\dA-F]{1,4}:){1,7}:)|(?:::))$#i';
break;
case 'url':
@@ -3399,25 +3462,110 @@ function short_ipv6($ip, $length)
/**
* Wrapper for php's checkdnsrr function.
*
-* The windows failover is from the php manual
-* Please make sure to check the return value for === true and === false, since NULL could
-* be returned too.
+* @param string $host Fully-Qualified Domain Name
+* @param string $type Resource record type to lookup
+* Supported types are: MX (default), A, AAAA, NS, TXT, CNAME
+* Other types may work or may not work
*
-* @return true if entry found, false if not, NULL if this function is not supported by this environment
+* @return mixed true if entry found,
+* false if entry not found,
+* null if this function is not supported by this environment
+*
+* Since null can also be returned, you probably want to compare the result
+* with === true or === false,
+*
+* @author bantu
*/
-function phpbb_checkdnsrr($host, $type = '')
+function phpbb_checkdnsrr($host, $type = 'MX')
{
- $type = (!$type) ? 'MX' : $type;
+ // The dot indicates to search the DNS root (helps those having DNS prefixes on the same domain)
+ if (substr($host, -1) == '.')
+ {
+ $host_fqdn = $host;
+ $host = substr($host, 0, -1);
+ }
+ else
+ {
+ $host_fqdn = $host . '.';
+ }
+ // $host has format some.host.example.com
+ // $host_fqdn has format some.host.example.com.
- if (DIRECTORY_SEPARATOR == '\\')
+ // If we're looking for an A record we can use gethostbyname()
+ if ($type == 'A' && function_exists('gethostbyname'))
{
- if (!function_exists('exec'))
+ return (@gethostbyname($host_fqdn) == $host_fqdn) ? false : true;
+ }
+
+ // checkdnsrr() is available on Windows since PHP 5.3,
+ // but until 5.3.3 it only works for MX records
+ // See: http://bugs.php.net/bug.php?id=51844
+
+ // Call checkdnsrr() if
+ // we're looking for an MX record or
+ // we're not on Windows or
+ // we're running a PHP version where #51844 has been fixed
+
+ // checkdnsrr() supports AAAA since 5.0.0
+ // checkdnsrr() supports TXT since 5.2.4
+ if (
+ ($type == 'MX' || DIRECTORY_SEPARATOR != '\\' || version_compare(PHP_VERSION, '5.3.3', '>=')) &&
+ ($type != 'AAAA' || version_compare(PHP_VERSION, '5.0.0', '>=')) &&
+ ($type != 'TXT' || version_compare(PHP_VERSION, '5.2.4', '>=')) &&
+ function_exists('checkdnsrr')
+ )
+ {
+ return checkdnsrr($host_fqdn, $type);
+ }
+
+ // dns_get_record() is available since PHP 5; since PHP 5.3 also on Windows,
+ // but on Windows it does not work reliable for AAAA records before PHP 5.3.1
+
+ // Call dns_get_record() if
+ // we're not looking for an AAAA record or
+ // we're not on Windows or
+ // we're running a PHP version where AAAA lookups work reliable
+ if (
+ ($type != 'AAAA' || DIRECTORY_SEPARATOR != '\\' || version_compare(PHP_VERSION, '5.3.1', '>=')) &&
+ function_exists('dns_get_record')
+ )
+ {
+ // dns_get_record() expects an integer as second parameter
+ // We have to convert the string $type to the corresponding integer constant.
+ $type_constant = 'DNS_' . $type;
+ $type_param = (defined($type_constant)) ? constant($type_constant) : DNS_ANY;
+
+ // dns_get_record() might throw E_WARNING and return false for records that do not exist
+ $resultset = @dns_get_record($host_fqdn, $type_param);
+
+ if (empty($resultset) || !is_array($resultset))
{
- return NULL;
+ return false;
+ }
+ else if ($type_param == DNS_ANY)
+ {
+ // $resultset is a non-empty array
+ return true;
+ }
+
+ foreach ($resultset as $result)
+ {
+ if (
+ isset($result['host']) && $result['host'] == $host &&
+ isset($result['type']) && $result['type'] == $type
+ )
+ {
+ return true;
+ }
}
- // @exec('nslookup -retry=1 -timout=1 -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host), $output);
- @exec('nslookup -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host) . '.', $output);
+ return false;
+ }
+
+ // If we're on Windows we can still try to call nslookup via exec() as a last resort
+ if (DIRECTORY_SEPARATOR == '\\' && function_exists('exec'))
+ {
+ @exec('nslookup -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host_fqdn), $output);
// If output is empty, the nslookup failed
if (empty($output))
@@ -3427,25 +3575,71 @@ function phpbb_checkdnsrr($host, $type = '')
foreach ($output as $line)
{
- if (!trim($line))
+ $line = trim($line);
+
+ if (empty($line))
{
continue;
}
- // Valid records begin with host name:
- if (strpos($line, $host) === 0)
+ // Squash tabs and multiple whitespaces to a single whitespace.
+ $line = preg_replace('/\s+/', ' ', $line);
+
+ switch ($type)
{
- return true;
+ case 'MX':
+ if (stripos($line, "$host MX") === 0)
+ {
+ return true;
+ }
+ break;
+
+ case 'NS':
+ if (stripos($line, "$host nameserver") === 0)
+ {
+ return true;
+ }
+ break;
+
+ case 'TXT':
+ if (stripos($line, "$host text") === 0)
+ {
+ return true;
+ }
+ break;
+
+ case 'CNAME':
+ if (stripos($line, "$host canonical name") === 0)
+ {
+ return true;
+ }
+
+ default:
+ case 'A':
+ case 'AAAA':
+ if (!empty($host_matches))
+ {
+ // Second line
+ if (stripos($line, "Address: ") === 0)
+ {
+ return true;
+ }
+ else
+ {
+ $host_matches = false;
+ }
+ }
+ else if (stripos($line, "Name: $host") === 0)
+ {
+ // First line
+ $host_matches = true;
+ }
+ break;
}
}
return false;
}
- else if (function_exists('checkdnsrr'))
- {
- // The dot indicates to search the DNS root (helps those having DNS prefixes on the same domain)
- return (checkdnsrr($host . '.', $type)) ? true : false;
- }
return NULL;
}
@@ -3559,7 +3753,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
}
// Do not send 200 OK, but service unavailable on errors
- header('HTTP/1.1 503 Service Unavailable');
+ send_status_line(503, 'Service Unavailable');
garbage_collection();
@@ -3628,6 +3822,11 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
$user->setup();
}
+ if ($msg_text == 'ERROR_NO_ATTACHMENT' || $msg_text == 'NO_FORUM' || $msg_text == 'NO_TOPIC' || $msg_text == 'NO_USER')
+ {
+ send_status_line(404, 'Not Found');
+ }
+
$msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text;
$msg_title = (!isset($msg_title)) ? $user->lang['INFORMATION'] : ((!empty($user->lang[$msg_title])) ? $user->lang[$msg_title] : $msg_title);
@@ -4024,7 +4223,8 @@ function phpbb_http_login($param)
}
else if ($auth_result['status'] == LOGIN_ERROR_ATTEMPTS)
{
- header('HTTP/1.0 401 Unauthorized');
+ send_status_line(401, 'Unauthorized');
+
trigger_error('NOT_AUTHORISED');
}
}
@@ -4036,7 +4236,7 @@ function phpbb_http_login($param)
$param['auth_message'] = preg_replace('/[\x80-\xFF]/', '?', $param['auth_message']);
header('WWW-Authenticate: Basic realm="' . $param['auth_message'] . '"');
- header('HTTP/1.0 401 Unauthorized');
+ send_status_line(401, 'Unauthorized');
trigger_error('NOT_AUTHORISED');
}
@@ -4266,6 +4466,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'S_ENABLE_FEEDS_TOPICS_ACTIVE' => ($config['feed_topics_active']) ? true : false,
'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false,
+ 'S_LOAD_UNREADS' => ($config['load_unreads_search'] && ($config['load_anon_lastread'] || $user->data['is_registered'])) ? true : false,
+
'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme',
'T_TEMPLATE_PATH' => "{$web_path}styles/" . $user->theme['template_path'] . '/template',
'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? "{$web_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$web_path}styles/" . $user->theme['template_path'] . '/template',
@@ -4278,7 +4480,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/",
'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/",
'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/",
- 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&amp;lang=' . $user->data['user_lang'], true, $user->session_id),
+ 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&amp;lang=' . $user->data['user_lang']),
'T_STYLESHEET_NAME' => $user->theme['theme_name'],
'T_THEME_NAME' => $user->theme['theme_path'],
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 93244be55c..3178d35c34 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -96,16 +96,12 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
$right = $row['right_id'];
$disabled = false;
- if (!$ignore_acl && $auth->acl_get('f_list', $row['forum_id']))
+ if (!$ignore_acl && $auth->acl_gets(array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id']))
{
if ($only_acl_post && !$auth->acl_get('f_post', $row['forum_id']) || (!$auth->acl_get('m_approve', $row['forum_id']) && !$auth->acl_get('f_noapprove', $row['forum_id'])))
{
$disabled = true;
}
- else if (!$only_acl_post && !$auth->acl_gets(array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id']))
- {
- $disabled = true;
- }
}
else if (!$ignore_acl)
{
@@ -577,8 +573,8 @@ function move_posts($post_ids, $topic_id, $auto_sync = true)
while ($row = $db->sql_fetchrow($result))
{
- $forum_ids[] = $row['forum_id'];
- $topic_ids[] = $row['topic_id'];
+ $forum_ids[] = (int) $row['forum_id'];
+ $topic_ids[] = (int) $row['topic_id'];
}
$db->sql_freeresult($result);
@@ -595,7 +591,7 @@ function move_posts($post_ids, $topic_id, $auto_sync = true)
}
$sql = 'UPDATE ' . POSTS_TABLE . '
- SET forum_id = ' . $forum_row['forum_id'] . ", topic_id = $topic_id
+ SET forum_id = ' . (int) $forum_row['forum_id'] . ", topic_id = $topic_id
WHERE " . $db->sql_in_set('post_id', $post_ids);
$db->sql_query($sql);
@@ -606,7 +602,7 @@ function move_posts($post_ids, $topic_id, $auto_sync = true)
if ($auto_sync)
{
- $forum_ids[] = $forum_row['forum_id'];
+ $forum_ids[] = (int) $forum_row['forum_id'];
sync('topic_reported', 'topic_id', $topic_ids);
sync('topic_attachment', 'topic_id', $topic_ids);
@@ -675,7 +671,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
$db->sql_transaction('begin');
- $table_ary = array(TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE);
+ $table_ary = array(BOOKMARKS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE);
foreach ($table_ary as $table)
{
@@ -1129,53 +1125,65 @@ function delete_attachments($mode, $ids, $resync = true)
}
/**
-* Remove topic shadows
+* Deletes shadow topics pointing to a specified forum.
+*
+* @param int $forum_id The forum id
+* @param string $sql_more Additional WHERE statement, e.g. t.topic_time < (time() - 1234)
+* @param bool $auto_sync Will call sync() if this is true
+*
+* @return array Array with affected forums
+*
+* @author bantu
*/
-function delete_topic_shadows($max_age, $forum_id = '', $auto_sync = true)
+function delete_topic_shadows($forum_id, $sql_more = '', $auto_sync = true)
{
- $where = (is_array($forum_id)) ? 'AND ' . $db->sql_in_set('t.forum_id', array_map('intval', $forum_id)) : (($forum_id) ? 'AND t.forum_id = ' . (int) $forum_id : '');
+ global $db;
- switch ($db->sql_layer)
+ if (!$forum_id)
{
- case 'mysql4':
- case 'mysqli':
- $sql = 'DELETE t.*
- FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TABLE . ' t2
- WHERE t.topic_moved_id = t2.topic_id
- AND t.topic_time < ' . (time() - $max_age)
- . $where;
- $db->sql_query($sql);
- break;
+ // Nothing to do.
+ return;
+ }
- default:
- $sql = 'SELECT t.topic_id
- FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TABLE . ' t2
- WHERE t.topic_moved_id = t2.topic_id
- AND t.topic_time < ' . (time() - $max_age)
- . $where;
- $result = $db->sql_query($sql);
+ // Set of affected forums we have to resync
+ $sync_forum_ids = array();
- $topic_ids = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $topic_ids[] = $row['topic_id'];
- }
- $db->sql_freeresult($result);
+ // Amount of topics we select and delete at once.
+ $batch_size = 500;
- if (sizeof($topic_ids))
- {
- $sql = 'DELETE FROM ' . TOPICS_TABLE . '
- WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
- $db->sql_query($sql);
- }
- break;
+ do
+ {
+ $sql = 'SELECT t2.forum_id, t2.topic_id
+ FROM ' . TOPICS_TABLE . ' t2, ' . TOPICS_TABLE . ' t
+ WHERE t2.topic_moved_id = t.topic_id
+ AND t.forum_id = ' . (int) $forum_id . '
+ ' . (($sql_more) ? 'AND ' . $sql_more : '');
+ $result = $db->sql_query_limit($sql, $batch_size);
+
+ $topic_ids = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $topic_ids[] = (int) $row['topic_id'];
+
+ $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id'];
+ }
+ $db->sql_freeresult($result);
+
+ if (!empty($topic_ids))
+ {
+ $sql = 'DELETE FROM ' . TOPICS_TABLE . '
+ WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
+ $db->sql_query($sql);
+ }
}
+ while (sizeof($topic_ids) == $batch_size);
if ($auto_sync)
{
- $where_type = ($forum_id) ? 'forum_id' : '';
- sync('forum', $where_type, $forum_id, true, true);
+ sync('forum', 'forum_id', $sync_forum_ids, true, true);
}
+
+ return $sync_forum_ids;
}
/**
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index f422eaa8c1..455debd939 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -53,13 +53,18 @@ class compress
$filelist = filelist("$phpbb_root_path$src", '', '*');
krsort($filelist);
+ /**
+ * Commented out, as adding the folders produces corrupted archives
if ($src_path)
{
$this->data($src_path, '', true, stat("$phpbb_root_path$src"));
}
+ */
foreach ($filelist as $path => $file_ary)
{
+ /**
+ * Commented out, as adding the folders produces corrupted archives
if ($path)
{
// Same as for src_path
@@ -68,6 +73,7 @@ class compress
$this->data("$src_path$path", '', true, stat("$phpbb_root_path$src$path"));
}
+ */
foreach ($file_ary as $file)
{
diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php
index 0fdae9b274..9e26043b39 100644
--- a/phpBB/includes/functions_convert.php
+++ b/phpBB/includes/functions_convert.php
@@ -1025,6 +1025,9 @@ function set_user_options()
'bbcode' => array('bit' => 8, 'default' => 1),
'smilies' => array('bit' => 9, 'default' => 1),
'popuppm' => array('bit' => 10, 'default' => 0),
+ 'sig_bbcode' => array('bit' => 15, 'default' => 1),
+ 'sig_smilies' => array('bit' => 16, 'default' => 1),
+ 'sig_links' => array('bit' => 17, 'default' => 1),
);
$option_field = 0;
@@ -2303,7 +2306,7 @@ function copy_file($src, $trg, $overwrite = false, $die_on_failure = true, $sour
}
}
- if (!is_writable($path))
+ if (!phpbb_is_writable($path))
{
@chmod($path, 0777);
}
@@ -2338,7 +2341,7 @@ function copy_dir($src, $trg, $copy_subdirs = true, $overwrite = false, $die_on_
@chmod($trg_path, 0777);
}
- if (!@is_writable($trg_path))
+ if (!phpbb_is_writable($trg_path))
{
$bad_dirs[] = path($config['script_path']) . $trg;
}
@@ -2405,7 +2408,7 @@ function copy_dir($src, $trg, $copy_subdirs = true, $overwrite = false, $die_on_
@chmod($trg_path . $dir, 0777);
}
- if (!@is_writable($trg_path . $dir))
+ if (!phpbb_is_writable($trg_path . $dir))
{
$bad_dirs[] = $trg . $dir;
$bad_dirs[] = $trg_path . $dir;
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index ea77551fc4..2de7e1b169 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -396,7 +396,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
}
else
{
- $folder_alt = ($forum_unread) ? 'NEW_POSTS' : 'NO_NEW_POSTS';
+ $folder_alt = ($forum_unread) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS';
}
// Create last post link information, if appropriate
@@ -425,7 +425,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
$s_subforums_list = array();
foreach ($subforums_list as $subforum)
{
- $s_subforums_list[] = '<a href="' . $subforum['link'] . '" class="subforum ' . (($subforum['unread']) ? 'unread' : 'read') . '" title="' . (($subforum['unread']) ? $user->lang['NEW_POSTS'] : $user->lang['NO_NEW_POSTS']) . '">' . $subforum['name'] . '</a>';
+ $s_subforums_list[] = '<a href="' . $subforum['link'] . '" class="subforum ' . (($subforum['unread']) ? 'unread' : 'read') . '" title="' . (($subforum['unread']) ? $user->lang['UNREAD_POSTS'] : $user->lang['NO_UNREAD_POSTS']) . '">' . $subforum['name'] . '</a>';
}
$s_subforums_list = (string) implode(', ', $s_subforums_list);
$catless = ($row['parent_id'] == $root_data['forum_id']) ? true : false;
@@ -854,7 +854,7 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold
$folder_img = ($unread_topic) ? $folder_new : $folder;
- $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
+ $folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS');
// Posted image?
if (!empty($topic_row['topic_posted']) && $topic_row['topic_posted'])
@@ -969,11 +969,16 @@ function display_user_activity(&$userdata)
$forum_ary = array_unique($forum_ary);
$forum_sql = (sizeof($forum_ary)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary, true) : '';
+ $fid_m_approve = $auth->acl_getf('m_approve', true);
+ $sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $db->sql_in_set('forum_id', array_keys($fid_m_approve)) : '';
+
// Obtain active forum
$sql = 'SELECT forum_id, COUNT(post_id) AS num_posts
FROM ' . POSTS_TABLE . '
WHERE poster_id = ' . $userdata['user_id'] . "
AND post_postcount = 1
+ AND (post_approved = 1
+ $sql_m_approve)
$forum_sql
GROUP BY forum_id
ORDER BY num_posts DESC";
@@ -996,6 +1001,8 @@ function display_user_activity(&$userdata)
FROM ' . POSTS_TABLE . '
WHERE poster_id = ' . $userdata['user_id'] . "
AND post_postcount = 1
+ AND (post_approved = 1
+ $sql_m_approve)
$forum_sql
GROUP BY topic_id
ORDER BY num_posts DESC";
@@ -1112,10 +1119,10 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
{
$is_watching = true;
- if ($notify_status)
+ if ($notify_status != NOTIFY_YES)
{
$sql = 'UPDATE ' . $table_sql . "
- SET notify_status = 0
+ SET notify_status = " . NOTIFY_YES . "
WHERE $where_sql = $match_id
AND user_id = $user_id";
$db->sql_query($sql);
@@ -1134,7 +1141,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
$is_watching = true;
$sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status)
- VALUES ($user_id, $match_id, 0)";
+ VALUES ($user_id, $match_id, " . NOTIFY_YES . ')';
$db->sql_query($sql);
$message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
}
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 227df95ac5..b5c87094c0 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -721,11 +721,18 @@ class queue
$package_size = $data_ary['package_size'];
$num_items = (!$package_size || sizeof($data_ary['data']) < $package_size) ? sizeof($data_ary['data']) : $package_size;
+ /*
+ * This code is commented out because it causes problems on some web hosts.
+ * The core problem is rather restrictive email sending limits.
+ * This code is nly useful if you have no such restrictions from the
+ * web host and the package size setting is wrong.
+
// If the amount of emails to be sent is way more than package_size than we need to increase it to prevent backlogs...
if (sizeof($data_ary['data']) > $package_size * 2.5)
{
$num_items = sizeof($data_ary['data']);
}
+ */
switch ($object)
{
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 21c5fe7aca..6fd87db663 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -348,7 +348,7 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
{
$topic_type_array = array_merge(array(0 => array(
'VALUE' => POST_NORMAL,
- 'S_CHECKED' => ($topic_type == POST_NORMAL) ? ' checked="checked"' : '',
+ 'S_CHECKED' => ($cur_topic_type == POST_NORMAL) ? ' checked="checked"' : '',
'L_TOPIC_TYPE' => $user->lang['POST_NORMAL'])),
$topic_type_array
@@ -1146,7 +1146,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
}
}
- unset($rowset[$i]);
+ unset($rowset[$post_list[$i]]);
}
if ($mode == 'topic_review')
@@ -1201,8 +1201,8 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u
WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . "
AND w.user_id NOT IN ($sql_ignore_users)
- AND w.notify_status = 0
- AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
+ AND w.notify_status = " . NOTIFY_YES . '
+ AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
AND u.user_id = w.user_id';
$result = $db->sql_query($sql);
@@ -1234,8 +1234,8 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u
WHERE fw.forum_id = $forum_id
AND fw.user_id NOT IN ($sql_ignore_users)
- AND fw.notify_status = 0
- AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
+ AND fw.notify_status = " . NOTIFY_YES . '
+ AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
AND u.user_id = fw.user_id';
$result = $db->sql_query($sql);
@@ -1344,8 +1344,8 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
if (!empty($update_notification['topic']))
{
- $sql = 'UPDATE ' . TOPICS_WATCH_TABLE . "
- SET notify_status = 1
+ $sql = 'UPDATE ' . TOPICS_WATCH_TABLE . '
+ SET notify_status = ' . NOTIFY_NO . "
WHERE topic_id = $topic_id
AND " . $db->sql_in_set('user_id', $update_notification['topic']);
$db->sql_query($sql);
@@ -1353,8 +1353,8 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
if (!empty($update_notification['forum']))
{
- $sql = 'UPDATE ' . FORUMS_WATCH_TABLE . "
- SET notify_status = 1
+ $sql = 'UPDATE ' . FORUMS_WATCH_TABLE . '
+ SET notify_status = ' . NOTIFY_NO . "
WHERE forum_id = $forum_id
AND " . $db->sql_in_set('user_id', $update_notification['forum']);
$db->sql_query($sql);
@@ -2537,7 +2537,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
if ($mode == 'post' || $mode == 'reply' || $mode == 'quote')
{
// Mark this topic as posted to
- markread('post', $data['forum_id'], $data['topic_id'], $data['post_time']);
+ markread('post', $data['forum_id'], $data['topic_id']);
}
// Mark this topic as read
@@ -2583,7 +2583,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
}
// Send Notifications
- if ($mode != 'edit' && $mode != 'delete' && $post_approval)
+ if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval)
{
user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id']);
}
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 4fc5034f7b..4c34bc92ca 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -1380,6 +1380,9 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
}
}
+ // First of all make sure the subject are having the correct length.
+ $subject = truncate_string($subject);
+
$db->sql_transaction('begin');
$sql = '';
@@ -1751,6 +1754,8 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
return false;
}
+ $title = $row['message_subject'];
+
$rowset = array();
$bbcode_bitfield = '';
$folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm') . '&amp;folder=';
@@ -1774,8 +1779,6 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
- $title = $row['message_subject'];
-
if (sizeof($rowset) == 1 && !$in_post_mode)
{
return false;
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php
index 61e3587158..3937cf9c21 100644
--- a/phpBB/includes/functions_profile_fields.php
+++ b/phpBB/includes/functions_profile_fields.php
@@ -366,6 +366,7 @@ class custom_profile
case 'sqlite':
case 'mssql':
case 'mssql_odbc':
+ case 'mssqlnative':
$right_delim = ']';
$left_delim = '[';
break;
@@ -542,8 +543,9 @@ class custom_profile
else if ($day && $month && $year)
{
global $user;
- // d/m/y 00:00 GMT isn't necessarily on the same d/m/y in the user's timezone, so add the timezone seconds
- return $user->format_date(gmmktime(0, 0, 0, $month, $day, $year) + $user->timezone + $user->dst, $user->lang['DATE_FORMAT'], true);
+ // Date should display as the same date for every user regardless of timezone, so remove offset
+ // to compensate for the offset added by user::format_date()
+ return $user->format_date(gmmktime(0, 0, 0, $month, $day, $year) - ($user->timezone + $user->dst), $user->lang['DATE_FORMAT'], true);
}
return $value;
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
index 054af29045..7f09cc1640 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -58,8 +58,9 @@ class filespec
$this->filename = $upload_ary['tmp_name'];
$this->filesize = $upload_ary['size'];
- $name = trim(utf8_htmlspecialchars(utf8_basename($upload_ary['name'])));
- $this->realname = $this->uploadname = (STRIP) ? stripslashes($name) : $name;
+ $name = (STRIP) ? stripslashes($upload_ary['name']) : $upload_ary['name'];
+ $name = trim(utf8_htmlspecialchars(utf8_basename($name)));
+ $this->realname = $this->uploadname = $name;
$this->mimetype = $upload_ary['type'];
// Opera adds the name to the mime type
@@ -775,7 +776,18 @@ class fileupload
{
if ($get_info)
{
- $data .= @fread($fsock, 1024);
+ $block = @fread($fsock, 1024);
+ $filesize += strlen($block);
+
+ if ($this->max_filesize && $filesize > $this->max_filesize)
+ {
+ $max_filesize = get_formatted_filesize($this->max_filesize, false);
+
+ $file = new fileerror(sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']));
+ return $file;
+ }
+
+ $data .= $block;
}
else
{
@@ -791,6 +803,18 @@ class fileupload
{
$upload_ary['type'] = rtrim(str_replace('content-type: ', '', strtolower($line)));
}
+ else if ($this->max_filesize && stripos($line, 'content-length: ') !== false)
+ {
+ $length = (int) str_replace('content-length: ', '', strtolower($line));
+
+ if ($length && $length > $this->max_filesize)
+ {
+ $max_filesize = get_formatted_filesize($this->max_filesize, false);
+
+ $file = new fileerror(sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit']));
+ return $file;
+ }
+ }
else if (stripos($line, '404 not found') !== false)
{
$file = new fileerror($user->lang[$this->error_prefix . 'URL_NOT_FOUND']);
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 21e82030ee..f2c80705ba 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -297,6 +297,7 @@ function user_add($user_row, $cp_data = false)
if ($config['new_member_group_default'])
{
group_user_add($add_group_id, $user_id, false, false, true);
+ $user_row['group_id'] = $add_group_id;
}
else
{
@@ -527,7 +528,7 @@ function user_delete($mode, $user_id, $post_username = false)
$db->sql_transaction('begin');
- $table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE, SESSIONS_KEYS_TABLE);
+ $table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE, SESSIONS_KEYS_TABLE, PRIVMSGS_FOLDER_TABLE, PRIVMSGS_RULES_TABLE);
foreach ($table_ary as $table)
{
@@ -765,7 +766,8 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
if (sizeof($ban_other) == 3 && ((int)$ban_other[0] < 9999) &&
(strlen($ban_other[0]) == 4) && (strlen($ban_other[1]) == 2) && (strlen($ban_other[2]) == 2))
{
- $ban_end = max($current_time, gmmktime(0, 0, 0, (int)$ban_other[1], (int)$ban_other[2], (int)$ban_other[0]));
+ $time_offset = (isset($user->timezone) && isset($user->dst)) ? (int) $user->timezone + (int) $user->dst : 0;
+ $ban_end = max($current_time, gmmktime(0, 0, 0, (int)$ban_other[1], (int)$ban_other[2], (int)$ban_other[0]) - $time_offset);
}
else
{
@@ -836,14 +838,15 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('username_clean', $sql_usernames);
- // Do not allow banning yourself
+ // Do not allow banning yourself, the guest account, or founders.
+ $non_bannable = array($user->data['user_id'], ANONYMOUS);
if (sizeof($founder))
{
- $sql .= ' AND ' . $db->sql_in_set('user_id', array_merge(array_keys($founder), array($user->data['user_id'])), true);
+ $sql .= ' AND ' . $db->sql_in_set('user_id', array_merge(array_keys($founder), $non_bannable), true);
}
else
{
- $sql .= ' AND user_id <> ' . $user->data['user_id'];
+ $sql .= ' AND ' . $db->sql_in_set('user_id', $non_bannable, true);
}
$result = $db->sql_query($sql);
@@ -1227,22 +1230,39 @@ function user_unban($mode, $ban)
}
/**
-* Whois facility
+* Internet Protocol Address Whois
+* RFC3912: WHOIS Protocol Specification
*
-* @link http://tools.ietf.org/html/rfc3912 RFC3912: WHOIS Protocol Specification
+* @param string $ip Ip address, either IPv4 or IPv6.
+*
+* @return string Empty string if not a valid ip address.
+* Otherwise make_clickable()'ed whois result.
*/
function user_ipwhois($ip)
{
- $ipwhois = '';
+ if (empty($ip))
+ {
+ return '';
+ }
- // Check IP
- // Only supporting IPv4 at the moment...
- if (empty($ip) || !preg_match(get_preg_expression('ipv4'), $ip))
+ if (preg_match(get_preg_expression('ipv4'), $ip))
+ {
+ // IPv4 address
+ $whois_host = 'whois.arin.net.';
+ }
+ else if (preg_match(get_preg_expression('ipv6'), $ip))
+ {
+ // IPv6 address
+ $whois_host = 'whois.sixxs.net.';
+ }
+ else
{
return '';
}
- if (($fsk = @fsockopen('whois.arin.net', 43)))
+ $ipwhois = '';
+
+ if (($fsk = @fsockopen($whois_host, 43)))
{
// CRLF as per RFC3912
fputs($fsk, "$ip\r\n");
@@ -1255,7 +1275,7 @@ function user_ipwhois($ip)
$match = array();
- // Test for referrals from ARIN to other whois databases, roll on rwhois
+ // Test for referrals from $whois_host to other whois databases, roll on rwhois
if (preg_match('#ReferralServer: whois://(.+)#im', $ipwhois, $match))
{
if (strpos($match[1], ':') !== false)
@@ -1283,7 +1303,7 @@ function user_ipwhois($ip)
@fclose($fsk);
}
- // Use the result from ARIN if we don't get any result here
+ // Use the result from $whois_host if we don't get any result here
$ipwhois = (empty($buffer)) ? $ipwhois : $buffer;
}
@@ -2283,7 +2303,7 @@ function avatar_get_dimensions($avatar, $avatar_type, &$error, $current_x = 0, $
/**
* Uploading/Changing user avatar
*/
-function avatar_process_user(&$error, $custom_userdata = false)
+function avatar_process_user(&$error, $custom_userdata = false, $can_upload = null)
{
global $config, $phpbb_root_path, $auth, $user, $db;
@@ -2322,7 +2342,10 @@ function avatar_process_user(&$error, $custom_userdata = false)
$avatar_select = basename(request_var('avatar_select', ''));
// Can we upload?
- $can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $change_avatar && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false;
+ if (is_null($can_upload))
+ {
+ $can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $change_avatar && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false;
+ }
if ((!empty($_FILES['uploadfile']['name']) || $data['uploadurl']) && $can_upload)
{
@@ -2347,7 +2370,7 @@ function avatar_process_user(&$error, $custom_userdata = false)
}
else
{
- list($sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $sql_ary['user_avatar']);
+ list($sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . urldecode($sql_ary['user_avatar']));
$sql_ary['user_avatar'] = $category . '/' . $sql_ary['user_avatar'];
}
}
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index 80c3559649..d5551f5114 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -1048,6 +1048,35 @@ function mcp_fork_topic($topic_ids)
$total_posts = 0;
$new_topic_id_list = array();
+ if ($topic_data['enable_indexing'])
+ {
+ // Select the search method and do some additional checks to ensure it can actually be utilised
+ $search_type = basename($config['search_type']);
+
+ if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx))
+ {
+ trigger_error('NO_SUCH_SEARCH_MODULE');
+ }
+
+ if (!class_exists($search_type))
+ {
+ include("{$phpbb_root_path}includes/search/$search_type.$phpEx");
+ }
+
+ $error = false;
+ $search = new $search_type($error);
+ $search_mode = 'post';
+
+ if ($error)
+ {
+ trigger_error($error);
+ }
+ }
+ else
+ {
+ $search_type = false;
+ }
+
foreach ($topic_data as $topic_id => $topic_row)
{
$sql_ary = array(
@@ -1158,6 +1187,12 @@ function mcp_fork_topic($topic_ids)
// Copy whether the topic is dotted
markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']);
+ if ($search_type)
+ {
+ $search->index($search_mode, $sql_ary['post_id'], $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id);
+ $search_mode = 'reply'; // After one we index replies
+ }
+
// Copy Attachments
if ($row['post_attachment'])
{
diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php
index fa44e006dd..7098b4bbce 100644
--- a/phpBB/includes/mcp/mcp_post.php
+++ b/phpBB/includes/mcp/mcp_post.php
@@ -176,7 +176,7 @@ function mcp_post_details($id, $mode, $action)
}
$template->assign_vars(array(
- 'U_MCP_ACTION' => "$url&amp;i=main&amp;quickmod=1", // Use this for mode paramaters
+ 'U_MCP_ACTION' => "$url&amp;i=main&amp;quickmod=1&amp;mode=post_details", // Use this for mode paramaters
'U_POST_ACTION' => "$url&amp;i=$id&amp;mode=post_details", // Use this for action parameters
'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&amp;p=$post_id&amp;f={$post_info['forum_id']}"),
@@ -200,7 +200,7 @@ function mcp_post_details($id, $mode, $action)
'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&amp;p=' . $post_info['post_id'] . '#p' . $post_info['post_id']),
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&amp;t=' . $post_info['topic_id']),
- 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
+ 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'),
'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$post_info['forum_id']}&amp;p=$post_id") . "#p$post_id\">", '</a>'),
'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$post_info['forum_id']}&amp;start={$start}") . '">', '</a>'),
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index 8d9ece5205..c419da5574 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -196,7 +196,7 @@ class mcp_queue
'U_VIEW_POST' => $post_url,
'U_VIEW_TOPIC' => $topic_url,
- 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
+ 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'),
'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue' . (($topic_id) ? '&amp;mode=unapproved_topics' : '&amp;mode=unapproved_posts')) . "&amp;start=$start\">", '</a>'),
'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'),
@@ -428,7 +428,7 @@ class mcp_queue
'POST_ID' => $row['post_id'],
'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'],
- 'POST_SUBJECT' => $row['post_subject'],
+ 'POST_SUBJECT' => ($row['post_subject'] != '') ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
'TOPIC_TITLE' => $row['topic_title'],
'POST_TIME' => $user->format_date($row['post_time']))
);
@@ -691,16 +691,19 @@ function approve_post($post_id_list, $id, $mode)
{
$show_notify = false;
- foreach ($post_info as $post_data)
+ if ($config['email_enable'] || $config['jab_enable'])
{
- if ($post_data['poster_id'] == ANONYMOUS)
- {
- continue;
- }
- else
+ foreach ($post_info as $post_data)
{
- $show_notify = true;
- break;
+ if ($post_data['poster_id'] == ANONYMOUS)
+ {
+ continue;
+ }
+ else
+ {
+ $show_notify = true;
+ break;
+ }
}
}
diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php
index e19fe96963..39d9fbd4af 100644
--- a/phpBB/includes/mcp/mcp_reports.php
+++ b/phpBB/includes/mcp/mcp_reports.php
@@ -205,7 +205,7 @@ class mcp_reports
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&amp;t=' . $post_info['topic_id']),
'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']),
- 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
+ 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'),
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']),
'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '<a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports' . (($post_info['post_reported']) ? '&amp;mode=reports' : '&amp;mode=reports_closed') . '&amp;start=' . $start . '&amp;f=' . $post_info['forum_id']) . '">', '</a>'),
diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php
index 9779478330..76cd9beb92 100644
--- a/phpBB/includes/mcp/mcp_topic.php
+++ b/phpBB/includes/mcp/mcp_topic.php
@@ -237,7 +237,7 @@ function mcp_topic_view($id, $mode, $action)
'POST_ID' => $row['post_id'],
'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id) . '">', '</a>'),
- 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
+ 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'),
'S_POST_REPORTED' => ($row['post_reported']) ? true : false,
'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true,
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 50aad8588a..952b55cc8c 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -300,7 +300,7 @@ class bbcode_firstpass extends bbcode
if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width'])
{
- $stats = @getimagesize($in);
+ $stats = @getimagesize(htmlspecialchars_decode($in));
if ($stats === false)
{
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index da3833754e..29cdd8ee9a 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -122,7 +122,7 @@ class fulltext_mysql extends search_backend
if ($terms == 'all')
{
- $match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#\+#', '#-#', '#\|#');
+ $match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#(^|\s)\+#', '#(^|\s)-#', '#(^|\s)\|#');
$replace = array(' +', ' |', ' -', ' +', ' -', ' |');
$keywords = preg_replace($match, $replace, $keywords);
@@ -919,6 +919,14 @@ class fulltext_mysql extends search_backend
<dt><label>' . $user->lang['FULLTEXT_MYSQL_MBSTRING'] . '</label><br /><span>' . $user->lang['FULLTEXT_MYSQL_MBSTRING_EXPLAIN'] . '</span></dt>
<dd>' . (($this->mbstring_regex) ? $user->lang['YES'] : $user->lang['NO']). '</dd>
</dl>
+ <dl>
+ <dt><label>' . $user->lang['MIN_SEARCH_CHARS'] . ':</label><br /><span>' . $user->lang['FULLTEXT_MYSQL_MIN_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
+ <dd>' . $config['fulltext_mysql_min_word_len'] . '</dd>
+ </dl>
+ <dl>
+ <dt><label>' . $user->lang['MAX_SEARCH_CHARS'] . ':</label><br /><span>' . $user->lang['FULLTEXT_MYSQL_MAX_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
+ <dd>' . $config['fulltext_mysql_max_word_len'] . '</dd>
+ </dl>
';
// These are fields required in the config table
diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php
index c89e92711e..727e3aaffb 100644
--- a/phpBB/includes/search/fulltext_native.php
+++ b/phpBB/includes/search/fulltext_native.php
@@ -83,7 +83,9 @@ class fulltext_native extends search_backend
{
global $db, $user, $config;
- $keywords = trim($this->cleanup($keywords, '+-|()*'));
+ $tokens = '+-|()*';
+
+ $keywords = trim($this->cleanup($keywords, $tokens));
// allow word|word|word without brackets
if ((strpos($keywords, ' ') === false) && (strpos($keywords, '|') !== false) && (strpos($keywords, '(') === false))
@@ -114,6 +116,15 @@ class fulltext_native extends search_backend
case ' ':
$keywords[$i] = '|';
break;
+ case '*':
+ if ($i === 0 || ($keywords[$i - 1] !== '*' && strcspn($keywords[$i - 1], $tokens) === 0))
+ {
+ if ($i === $n - 1 || ($keywords[$i + 1] !== '*' && strcspn($keywords[$i + 1], $tokens) === 0))
+ {
+ $keywords = substr($keywords, 0, $i) . substr($keywords, $i + 1);
+ }
+ }
+ break;
}
}
else
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 0a01b4e73b..5f5b39fe27 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -285,6 +285,17 @@ class session
break;
}
+ // Quick check for IPv4-mapped address in IPv6
+ if (stripos($ip, '::ffff:') === 0)
+ {
+ $ipv4 = substr($ip, 7);
+
+ if (preg_match(get_preg_expression('ipv4'), $ipv4))
+ {
+ $ip = $ipv4;
+ }
+ }
+
// Use the last in chain
$this->ip = $ip;
}
@@ -748,7 +759,7 @@ class session
if ((int) $row['sessions'] > (int) $config['active_sessions'])
{
- header('HTTP/1.1 503 Service Unavailable');
+ send_status_line(503, 'Service Unavailable');
trigger_error('BOARD_UNAVAILABLE');
}
}
@@ -1821,7 +1832,7 @@ class user extends session
{
if ($this->data['is_bot'])
{
- header('HTTP/1.1 503 Service Unavailable');
+ send_status_line(503, 'Service Unavailable');
}
$message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE';
@@ -1831,7 +1842,7 @@ class user extends session
// Is load exceeded?
if ($config['limit_load'] && $this->load !== false)
{
- if ($this->load > floatval($config['limit_load']) && !defined('IN_LOGIN'))
+ if ($this->load > floatval($config['limit_load']) && !defined('IN_LOGIN') && !defined('IN_ADMIN'))
{
// Set board disabled to true to let the admins/mods get the proper notification
$config['board_disable'] = '1';
@@ -1840,7 +1851,7 @@ class user extends session
{
if ($this->data['is_bot'])
{
- header('HTTP/1.1 503 Service Unavailable');
+ send_status_line(503, 'Service Unavailable');
}
trigger_error('BOARD_UNAVAILABLE');
}
@@ -2134,9 +2145,9 @@ class user extends session
// Zone offset
$zone_offset = $this->timezone + $this->dst;
- // Show date <= 1 hour ago as 'xx min ago'
+ // Show date <= 1 hour ago as 'xx min ago' but not greater than 60 seconds in the future
// A small tolerence is given for times in the future but in the same minute are displayed as '< than a minute ago'
- if ($delta <= 3600 && ($delta >= -5 || (($now / 60) % 60) == (($gmepoch / 60) % 60)) && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO']))
+ if ($delta <= 3600 && $delta > -60 && ($delta >= -5 || (($now / 60) % 60) == (($gmepoch / 60) % 60)) && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO']))
{
return $this->lang(array('datetime', 'AGO'), max(0, (int) floor($delta / 60)));
}
diff --git a/phpBB/includes/ucp/info/ucp_profile.php b/phpBB/includes/ucp/info/ucp_profile.php
index 03a4c81f46..d19b80f4c0 100644
--- a/phpBB/includes/ucp/info/ucp_profile.php
+++ b/phpBB/includes/ucp/info/ucp_profile.php
@@ -22,7 +22,7 @@ class ucp_profile_info
'modes' => array(
'profile_info' => array('title' => 'UCP_PROFILE_PROFILE_INFO', 'auth' => '', 'cat' => array('UCP_PROFILE')),
'signature' => array('title' => 'UCP_PROFILE_SIGNATURE', 'auth' => '', 'cat' => array('UCP_PROFILE')),
- 'avatar' => array('title' => 'UCP_PROFILE_AVATAR', 'auth' => '', 'cat' => array('UCP_PROFILE')),
+ 'avatar' => array('title' => 'UCP_PROFILE_AVATAR', 'auth' => 'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)', 'cat' => array('UCP_PROFILE')),
'reg_details' => array('title' => 'UCP_PROFILE_REG_DETAILS', 'auth' => '', 'cat' => array('UCP_PROFILE')),
),
);
diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php
index 423d9b718a..1c055a4823 100644
--- a/phpBB/includes/ucp/ucp_groups.php
+++ b/phpBB/includes/ucp/ucp_groups.php
@@ -490,7 +490,7 @@ class ucp_groups
$avatar_select = basename(request_var('avatar_select', ''));
$category = basename(request_var('category', ''));
- $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false;
+ $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false;
// Did we submit?
if ($update)
diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php
index 6ac2412ef0..a6f71669ce 100644
--- a/phpBB/includes/ucp/ucp_main.php
+++ b/phpBB/includes/ucp/ucp_main.php
@@ -119,7 +119,7 @@ class ucp_main
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
$folder_img = ($unread_topic) ? $folder_new : $folder;
- $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
+ $folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS');
if ($row['topic_status'] == ITEM_LOCKED)
{
@@ -318,7 +318,7 @@ class ucp_main
else
{
$folder_image = ($unread_forum) ? 'forum_unread' : 'forum_read';
- $folder_alt = ($unread_forum) ? 'NEW_POSTS' : 'NO_NEW_POSTS';
+ $folder_alt = ($unread_forum) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS';
}
// Create last post link information, if appropriate
diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php
index 4d72d45f81..b596e72c41 100644
--- a/phpBB/includes/ucp/ucp_pm_compose.php
+++ b/phpBB/includes/ucp/ucp_pm_compose.php
@@ -1054,7 +1054,7 @@ function compose_pm($id, $mode, $action)
'S_COMPOSE_PM' => true,
'S_EDIT_POST' => ($action == 'edit'),
'S_SHOW_PM_ICONS' => $s_pm_icons,
- 'S_BBCODE_ALLOWED' => $bbcode_status,
+ 'S_BBCODE_ALLOWED' => ($bbcode_status) ? 1 : 0,
'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '',
'S_SMILIES_ALLOWED' => $smilies_status,
'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '',
diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php
index 665dd2c83f..6b7172ca2b 100644
--- a/phpBB/includes/ucp/ucp_pm_viewfolder.php
+++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php
@@ -170,10 +170,12 @@ function view_folder($id, $mode, $folder_id, $folder)
'ATTACH_ICON_IMG' => ($auth->acl_get('u_pm_download') && $row['message_attachment'] && $config['allow_pm_attach']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
'S_PM_DELETED' => ($row['pm_deleted']) ? true : false,
+ 'S_PM_REPORTED' => (isset($row['report_id'])) ? true : false,
'S_AUTHOR_DELETED' => ($row['author_id'] == ANONYMOUS) ? true : false,
'U_VIEW_PM' => ($row['pm_deleted']) ? '' : $view_message_url,
'U_REMOVE_PM' => ($row['pm_deleted']) ? $remove_message_url : '',
+ 'U_MCP_REPORT' => (isset($row['report_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&amp;mode=pm_report_details&amp;r=' . $row['report_id']) : '',
'RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '')
);
}
@@ -183,6 +185,7 @@ function view_folder($id, $mode, $folder_id, $folder)
'S_SHOW_RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? true : false,
'S_SHOW_COLOUR_LEGEND' => true,
+ 'REPORTED_IMG' => $user->img('icon_topic_reported', 'PM_REPORTED'),
'S_PM_ICONS' => ($config['enable_pm_icons']) ? true : false)
);
}
@@ -502,7 +505,7 @@ function get_pm_from($folder_id, $folder, $user_id)
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
}
- $sql = 'SELECT t.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.username_clean, u.user_colour
+ $sql = 'SELECT t.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.username_clean, u.user_colour, p.message_reported
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u
WHERE t.user_id = $user_id
AND p.author_id = u.user_id
@@ -512,13 +515,34 @@ function get_pm_from($folder_id, $folder, $user_id)
ORDER BY $sql_sort_order";
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
+ $pm_reported = array();
while ($row = $db->sql_fetchrow($result))
{
$rowset[$row['msg_id']] = $row;
$pm_list[] = $row['msg_id'];
+ if ($row['message_reported'])
+ {
+ $pm_reported[] = $row['msg_id'];
+ }
}
$db->sql_freeresult($result);
+ // Fetch the report_ids, if there are any reported pms.
+ if (!empty($pm_reported) && $auth->acl_getf_global('m_report'))
+ {
+ $sql = 'SELECT pm_id, report_id
+ FROM ' . REPORTS_TABLE . '
+ WHERE report_closed = 0
+ AND ' . $db->sql_in_set('pm_id', $pm_reported);
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $rowset[$row['pm_id']]['report_id'] = $row['report_id'];
+ }
+ $db->sql_freeresult($result);
+ }
+
$pm_list = ($store_reverse) ? array_reverse($pm_list) : $pm_list;
return array(
diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php
index 26968e1382..16700c490c 100644
--- a/phpBB/includes/ucp/ucp_pm_viewmessage.php
+++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php
@@ -309,7 +309,7 @@ function get_user_information($user_id, $user_row)
get_user_rank($user_row['user_rank'], $user_row['user_posts'], $user_row['rank_title'], $user_row['rank_image'], $user_row['rank_image_src']);
- if (!empty($user_row['user_allow_viewemail']) || $auth->acl_get('a_email'))
+ if ((!empty($user_row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
{
$user_row['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&amp;u=$user_id") : ((($config['board_hide_emails'] && !$auth->acl_get('a_email')) || empty($user_row['user_email'])) ? '' : 'mailto:' . $user_row['user_email']);
}
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index f4f4abad4a..c099e3b3fa 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -141,10 +141,7 @@ class ucp_profile
$server_url = generate_board_url();
- $user_actkey = gen_rand_string(10);
- $key_len = 54 - (strlen($server_url));
- $key_len = ($key_len > 6) ? $key_len : 6;
- $user_actkey = substr($user_actkey, 0, $key_len);
+ $user_actkey = gen_rand_string(mt_rand(6, 10));
$messenger = new messenger(false);
@@ -564,7 +561,7 @@ class ucp_profile
$avatar_select = basename(request_var('avatar_select', ''));
$category = basename(request_var('category', ''));
- $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false;
+ $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false;
add_form_key('ucp_avatar');
@@ -572,7 +569,7 @@ class ucp_profile
{
if (check_form_key('ucp_avatar'))
{
- if (avatar_process_user($error))
+ if (avatar_process_user($error, false, $can_upload))
{
meta_refresh(3, $this->u_action);
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php
index 9656a4a3af..7fd99da55a 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -286,11 +286,7 @@ class ucp_register
$config['require_activation'] == USER_ACTIVATION_SELF ||
$config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable'])
{
- $user_actkey = gen_rand_string(10);
- $key_len = 54 - (strlen($server_url));
- $key_len = ($key_len < 6) ? 6 : $key_len;
- $user_actkey = substr($user_actkey, 0, $key_len);
-
+ $user_actkey = gen_rand_string(mt_rand(6, 10));
$user_type = USER_INACTIVE;
$user_inactive_reason = INACTIVE_REGISTER;
$user_inactive_time = time();
diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php
index f9b792de20..cb89ad99be 100644
--- a/phpBB/includes/ucp/ucp_remind.php
+++ b/phpBB/includes/ucp/ucp_remind.php
@@ -79,10 +79,10 @@ class ucp_remind
// Make password at least 8 characters long, make it longer if admin wants to.
// gen_rand_string() however has a limit of 12 or 13.
- $user_password = gen_rand_string(max(8, rand((int) $config['min_pass_chars'], (int) $config['max_pass_chars'])));
+ $user_password = gen_rand_string_friendly(max(8, mt_rand((int) $config['min_pass_chars'], (int) $config['max_pass_chars'])));
// For the activation key a random length between 6 and 10 will do.
- $user_actkey = gen_rand_string(rand(6, 10));
+ $user_actkey = gen_rand_string(mt_rand(6, 10));
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_newpasswd = '" . $db->sql_escape(phpbb_hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "'