aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/acp/acp_attachments.php16
-rw-r--r--phpBB/includes/acp/acp_board.php43
-rw-r--r--phpBB/includes/acp/acp_captcha.php8
-rw-r--r--phpBB/includes/acp/acp_database.php33
-rw-r--r--phpBB/includes/acp/acp_forums.php22
-rw-r--r--phpBB/includes/acp/acp_groups.php36
-rw-r--r--phpBB/includes/acp/acp_icons.php4
-rw-r--r--[-rwxr-xr-x]phpBB/includes/acp/acp_inactive.php0
-rw-r--r--phpBB/includes/acp/acp_main.php9
-rw-r--r--phpBB/includes/acp/acp_permissions.php2
-rw-r--r--phpBB/includes/acp/acp_styles.php9
-rw-r--r--[-rwxr-xr-x]phpBB/includes/acp/info/acp_inactive.php0
-rw-r--r--phpBB/includes/auth.php2
-rw-r--r--phpBB/includes/auth/auth_apache.php6
-rw-r--r--phpBB/includes/constants.php5
-rw-r--r--phpBB/includes/functions.php48
-rw-r--r--phpBB/includes/functions_admin.php4
-rw-r--r--phpBB/includes/functions_compress.php68
-rw-r--r--phpBB/includes/functions_content.php6
-rw-r--r--phpBB/includes/functions_install.php2
-rw-r--r--phpBB/includes/functions_jabber.php3
-rw-r--r--phpBB/includes/functions_posting.php11
-rw-r--r--phpBB/includes/functions_privmsgs.php26
-rw-r--r--phpBB/includes/functions_upload.php63
-rw-r--r--phpBB/includes/functions_user.php32
-rw-r--r--phpBB/includes/mcp/mcp_ban.php43
-rw-r--r--[-rwxr-xr-x]phpBB/includes/mcp/mcp_logs.php0
-rw-r--r--phpBB/includes/mcp/mcp_main.php18
-rw-r--r--[-rwxr-xr-x]phpBB/includes/mcp/mcp_notes.php0
-rw-r--r--phpBB/includes/mcp/mcp_queue.php6
-rw-r--r--[-rwxr-xr-x]phpBB/includes/mcp/mcp_reports.php6
-rw-r--r--phpBB/includes/mcp/mcp_topic.php4
-rw-r--r--[-rwxr-xr-x]phpBB/includes/mcp/mcp_warn.php6
-rw-r--r--phpBB/includes/message_parser.php6
-rw-r--r--phpBB/includes/search/fulltext_mysql.php4
-rw-r--r--[-rwxr-xr-x]phpBB/includes/search/fulltext_native.php6
-rw-r--r--[-rwxr-xr-x]phpBB/includes/search/search.php0
-rw-r--r--phpBB/includes/session.php87
-rw-r--r--phpBB/includes/ucp/ucp_confirm.php4
-rw-r--r--phpBB/includes/ucp/ucp_pm.php19
-rw-r--r--phpBB/includes/ucp/ucp_pm_compose.php8
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewfolder.php2
-rw-r--r--phpBB/includes/utf/utf_tools.php2
43 files changed, 507 insertions, 172 deletions
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php
index c60f453238..4e8a8ef719 100644
--- a/phpBB/includes/acp/acp_attachments.php
+++ b/phpBB/includes/acp/acp_attachments.php
@@ -117,7 +117,9 @@ class acp_attachments
'max_attachments_pm' => array('lang' => 'MAX_ATTACHMENTS_PM', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => false),
'secure_downloads' => array('lang' => 'SECURE_DOWNLOADS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'secure_allow_deny' => array('lang' => 'SECURE_ALLOW_DENY', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_allow_deny', 'explain' => true),
- 'secure_allow_empty_referer' => array('lang' => 'SECURE_EMPTY_REFERRER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'secure_allow_empty_referer' => array('lang' => 'SECURE_EMPTY_REFERRER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'check_attachment_content' => array('lang' => 'CHECK_CONTENT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+
'legend2' => $l_legend_cat_images,
'img_display_inlined' => array('lang' => 'DISPLAY_INLINED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
@@ -156,7 +158,7 @@ class acp_attachments
if (in_array($config_name, array('attachment_quota', 'max_filesize', 'max_filesize_pm')))
{
$size_var = request_var($config_name, '');
- $this->new_config[$config_name] = $config_value = ($size_var == 'kb') ? ($config_value << 10) : (($size_var == 'mb') ? ($config_value << 20) : $config_value);
+ $this->new_config[$config_name] = $config_value = ($size_var == 'kb') ? round($config_value * 1024) : (($size_var == 'mb') ? round($config_value * 1048576) : $config_value);
}
if ($submit)
@@ -277,13 +279,19 @@ class acp_attachments
{
$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
+
+ $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
+ if (empty($content))
+ {
+ continue;
+ }
$template->assign_block_vars('options', array(
'KEY' => $config_key,
'TITLE' => $user->lang[$vars['lang']],
'S_EXPLAIN' => $vars['explain'],
'TITLE_EXPLAIN' => $l_explain,
- 'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars),
+ 'CONTENT' => $content,
)
);
@@ -504,7 +512,7 @@ class acp_attachments
$allowed_forums = request_var('allowed_forums', array(0));
$allow_in_pm = (isset($_POST['allow_in_pm'])) ? true : false;
$max_filesize = request_var('max_filesize', 0);
- $max_filesize = ($size_select == 'kb') ? ($max_filesize << 10) : (($size_select == 'mb') ? ($max_filesize << 20) : $max_filesize);
+ $max_filesize = ($size_select == 'kb') ? round($max_filesize * 1024) : (($size_select == 'mb') ? round($max_filesize * 1048576) : $max_filesize);
$allow_group = (isset($_POST['allow_group'])) ? true : false;
if ($max_filesize == $config['max_filesize'])
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index 1b7ae383cc..a7abae286a 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -164,21 +164,21 @@ class acp_board
'legend2' => 'POSTING',
'bump_type' => false,
- 'edit_time' => array('lang' => 'EDIT_TIME', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
- 'display_last_edited' => array('lang' => 'DISPLAY_LAST_EDITED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- 'flood_interval' => array('lang' => 'FLOOD_INTERVAL', 'validate' => 'int:0', 'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
- 'bump_interval' => array('lang' => 'BUMP_INTERVAL', 'validate' => 'int:0', 'type' => 'custom', 'method' => 'bump_interval', 'explain' => true),
- 'topics_per_page' => array('lang' => 'TOPICS_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false),
- 'posts_per_page' => array('lang' => 'POSTS_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false),
- 'hot_threshold' => array('lang' => 'HOT_THRESHOLD', 'validate' => 'int:0', 'type' => 'text:3:4', 'explain' => true),
- 'max_poll_options' => array('lang' => 'MAX_POLL_OPTIONS', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => false),
- 'max_post_chars' => array('lang' => 'CHAR_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:6', 'explain' => true),
- 'max_post_smilies' => array('lang' => 'SMILIES_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true),
- 'max_post_urls' => array('lang' => 'MAX_POST_URLS', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true),
- 'max_post_font_size' => array('lang' => 'MAX_POST_FONT_SIZE', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
- 'max_quote_depth' => array('lang' => 'QUOTE_DEPTH_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true),
- 'max_post_img_width' => array('lang' => 'MAX_POST_IMG_WIDTH', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
- 'max_post_img_height' => array('lang' => 'MAX_POST_IMG_HEIGHT', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
+ 'edit_time' => array('lang' => 'EDIT_TIME', 'validate' => 'int:0', 'type' => 'text:5:5', 'explain' => true, 'append' => ' ' . $user->lang['MINUTES']),
+ 'display_last_edited' => array('lang' => 'DISPLAY_LAST_EDITED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'flood_interval' => array('lang' => 'FLOOD_INTERVAL', 'validate' => 'int:0', 'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']),
+ 'bump_interval' => array('lang' => 'BUMP_INTERVAL', 'validate' => 'int:0', 'type' => 'custom', 'method' => 'bump_interval', 'explain' => true),
+ 'topics_per_page' => array('lang' => 'TOPICS_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false),
+ 'posts_per_page' => array('lang' => 'POSTS_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false),
+ 'hot_threshold' => array('lang' => 'HOT_THRESHOLD', 'validate' => 'int:0', 'type' => 'text:3:4', 'explain' => true),
+ 'max_poll_options' => array('lang' => 'MAX_POLL_OPTIONS', 'validate' => 'int:2:127', 'type' => 'text:4:4', 'explain' => false),
+ 'max_post_chars' => array('lang' => 'CHAR_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:6', 'explain' => true),
+ 'max_post_smilies' => array('lang' => 'SMILIES_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true),
+ 'max_post_urls' => array('lang' => 'MAX_POST_URLS', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true),
+ 'max_post_font_size' => array('lang' => 'MAX_POST_FONT_SIZE', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' %'),
+ 'max_quote_depth' => array('lang' => 'QUOTE_DEPTH_LIMIT', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => true),
+ 'max_post_img_width' => array('lang' => 'MAX_POST_IMG_WIDTH', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
+ 'max_post_img_height' => array('lang' => 'MAX_POST_IMG_HEIGHT', 'validate' => 'int:0', 'type' => 'text:5:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
)
);
break;
@@ -323,6 +323,7 @@ class acp_board
'ip_check' => array('lang' => 'IP_VALID', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_ip_check', 'explain' => true),
'browser_check' => array('lang' => 'BROWSER_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'forwarded_for_check' => array('lang' => 'FORWARDED_FOR_VALID', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'referer_validation' => array('lang' => 'REFERER_VALID', 'validate' => 'int:0:3','type' => 'custom', 'method' => 'select_ref_check', 'explain' => true),
'check_dnsbl' => array('lang' => 'CHECK_DNSBL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'email_check_mx' => array('lang' => 'EMAIL_CHECK_MX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'pass_complex' => array('lang' => 'PASSWORD_TYPE', 'validate' => 'string', 'type' => 'select', 'method' => 'select_password_chars', 'explain' => true),
@@ -569,7 +570,7 @@ class acp_board
'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
'S_EXPLAIN' => $vars['explain'],
'TITLE_EXPLAIN' => $l_explain,
- 'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars),
+ 'CONTENT' => $content,
)
);
@@ -676,7 +677,17 @@ class acp_board
return h_radio('config[ip_check]', $radio_ary, $value, $key);
}
+
+ /**
+ * Select referer validation
+ */
+ function select_ref_check($value, $key = '')
+ {
+ $radio_ary = array(REFERER_VALIDATE_PATH => 'REF_PATH', REFERER_VALIDATE_HOST => 'REF_HOST', REFERER_VALIDATE_NONE => 'NO_REF_VALIDATION');
+ return h_radio('config[referer_validation]', $radio_ary, $value, $key);
+ }
+
/**
* Select account activation method
*/
diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php
index 0d653c22d1..18523506a4 100644
--- a/phpBB/includes/acp/acp_captcha.php
+++ b/phpBB/includes/acp/acp_captcha.php
@@ -29,7 +29,7 @@ class acp_captcha
$user->add_lang('acp/board');
-
+
$captcha_vars = array(
'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID',
'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID',
@@ -54,7 +54,7 @@ class acp_captcha
}
$captcha = new captcha();
$captcha->execute(gen_rand_string(mt_rand(5, 8)), time());
- exit_handler();
+ exit;
}
$config_vars = array(
@@ -90,7 +90,7 @@ class acp_captcha
}
else
{
-
+
$preview_image_src = append_sid(append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&amp;demo=demo"));
if (@extension_loaded('gd'))
{
@@ -110,7 +110,7 @@ class acp_captcha
'CAPTCHA_PREVIEW' => $preview_image_src,
'PREVIEW' => isset($_POST['preview']),
));
-
+
}
}
}
diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php
index 1600aa266d..5b479a08eb 100644
--- a/phpBB/includes/acp/acp_database.php
+++ b/phpBB/includes/acp/acp_database.php
@@ -25,7 +25,7 @@ class acp_database
function main($id, $mode)
{
- global $db, $user, $auth, $template, $table_prefix;
+ global $cache, $db, $user, $auth, $template, $table_prefix;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang('acp/database');
@@ -159,18 +159,20 @@ class acp_database
$extractor->write_end();
+ add_log('admin', 'LOG_DB_BACKUP');
+
if ($download == true)
{
exit;
}
- add_log('admin', 'LOG_DB_BACKUP');
trigger_error($user->lang['BACKUP_SUCCESS'] . adm_back_link($this->u_action));
break;
default:
include($phpbb_root_path . 'includes/functions_install.' . $phpEx);
$tables = get_tables($db);
+ asort($tables);
foreach ($tables as $table_name)
{
if (strlen($table_prefix) === 0 || stripos($table_name, $table_prefix) === 0)
@@ -345,7 +347,25 @@ class acp_database
while (($sql = $fgetd($fp, $delim, $read, $seek, $eof)) !== false)
{
$query = trim($sql);
- $db->sql_query($query);
+
+ if (substr($query, 0, 13) == 'CREATE DOMAIN')
+ {
+ list(, , $domain) = explode(' ', $query);
+ $sql = "SELECT domain_name
+ FROM information_schema.domains
+ WHERE domain_name = '$domain';";
+ $result = $db->sql_query($sql);
+ if (!$db->sql_fetchrow($result))
+ {
+ $db->sql_query($query);
+ }
+ $db->sql_freeresult($result);
+ }
+ else
+ {
+ $db->sql_query($query);
+ }
+
if (substr($query, 0, 4) == 'COPY')
{
while (($sub = $fgetd($fp, "\n", $read, $seek, $eof)) !== '\.')
@@ -380,6 +400,9 @@ class acp_database
$close($fp);
+ // Purge the cache due to updated data
+ $cache->purge();
+
add_log('admin', 'LOG_DB_RESTORE');
trigger_error($user->lang['RESTORE_SUCCESS'] . adm_back_link($this->u_action));
break;
@@ -1087,7 +1110,7 @@ class postgres_extractor extends base_extractor
}
$sql_data = '-- Table: ' . $table_name . "\n";
- //$sql_data .= "DROP TABLE $table_name;\n";
+ $sql_data .= "DROP TABLE $table_name;\n";
// PGSQL does not "tightly" bind sequences and tables, we must guess...
$sql = "SELECT relname
FROM pg_class
@@ -1156,7 +1179,7 @@ class postgres_extractor extends base_extractor
$line .= ')';
}
- if (!empty($row['rowdefault']))
+ if (isset($row['rowdefault']))
{
$line .= ' DEFAULT ' . $row['rowdefault'];
}
diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php
index 99e53b8667..8c05cce5b1 100644
--- a/phpBB/includes/acp/acp_forums.php
+++ b/phpBB/includes/acp/acp_forums.php
@@ -56,7 +56,7 @@ class acp_forums
$total = request_var('total', 0);
$this->display_progress_bar($start, $total);
- exit_handler();
+ exit;
break;
case 'delete':
@@ -74,7 +74,7 @@ class acp_forums
{
trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
}
-
+
break;
}
@@ -100,7 +100,7 @@ class acp_forums
$cache->destroy('sql', FORUMS_TABLE);
trigger_error($user->lang['FORUM_DELETED'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id));
-
+
break;
case 'edit':
@@ -189,7 +189,7 @@ class acp_forums
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
WHERE forum_id = ' . (int) $forum_data['forum_id'];
$db->sql_query($sql);
-
+
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
WHERE forum_id = ' . (int) $forum_data['forum_id'];
$db->sql_query($sql);
@@ -245,7 +245,7 @@ class acp_forums
$auth->acl_clear_prefetch();
$cache->destroy('sql', FORUMS_TABLE);
-
+
$acl_url = '&amp;mode=setting_forum_local&amp;forum_id[]=' . $forum_data['forum_id'];
$message = ($action == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED'];
@@ -543,7 +543,7 @@ class acp_forums
$forum_type_options = '';
$forum_type_ary = array(FORUM_CAT => 'CAT', FORUM_POST => 'FORUM', FORUM_LINK => 'LINK');
-
+
foreach ($forum_type_ary as $value => $lang)
{
$forum_type_options .= '<option value="' . $value . '"' . (($value == $forum_data['forum_type']) ? ' selected="selected"' : '') . '>' . $user->lang['TYPE_' . $lang] . '</option>';
@@ -613,7 +613,7 @@ class acp_forums
}
}
}
-
+
if (strlen($forum_data['forum_password']) == 32)
{
$errors[] = $user->lang['FORUM_PASSWORD_OLD'];
@@ -918,7 +918,7 @@ class acp_forums
$forum_data['prune_days'] = $forum_data['prune_viewed'] = $forum_data['prune_freq'] = 0;
$errors[] = $user->lang['FORUM_DATA_NEGATIVE'];
}
-
+
$range_test_ary = array(
array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data['forum_topics_per_page'], 'column_type' => 'TINT:0'),
);
@@ -974,7 +974,7 @@ class acp_forums
$forum_data_sql['forum_password'] = phpbb_hash($forum_data_sql['forum_password']);
}
unset($forum_data_sql['forum_password_unset']);
-
+
if (!isset($forum_data_sql['forum_id']))
{
// no forum_id means we're creating a new forum
@@ -1632,7 +1632,7 @@ class acp_forums
WHERE p.forum_id = $forum_id
AND a.in_message = 0
AND a.topic_id = p.topic_id";
- $result = $db->sql_query($sql);
+ $result = $db->sql_query($sql);
$topic_ids = array();
while ($row = $db->sql_fetchrow($result))
@@ -1690,7 +1690,7 @@ class acp_forums
break;
default:
-
+
// Delete everything else and curse your DB for not offering multi-table deletion
$tables_ary = array(
'post_id' => array(
diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php
index eb785ced23..6d789fb5ff 100644
--- a/phpBB/includes/acp/acp_groups.php
+++ b/phpBB/includes/acp/acp_groups.php
@@ -87,24 +87,32 @@ class acp_groups
// Approve, demote or promote
$group_name = ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'];
- group_user_attributes($action, $group_id, $mark_ary, false, $group_name);
-
- switch ($action)
+ $error = group_user_attributes($action, $group_id, $mark_ary, false, $group_name);
+
+ if (!$error)
{
- case 'demote':
- $message = 'GROUP_MODS_DEMOTED';
- break;
+ switch ($action)
+ {
+ case 'demote':
+ $message = 'GROUP_MODS_DEMOTED';
+ break;
- case 'promote':
- $message = 'GROUP_MODS_PROMOTED';
- break;
+ case 'promote':
+ $message = 'GROUP_MODS_PROMOTED';
+ break;
- case 'approve':
- $message = 'USERS_APPROVED';
- break;
- }
+ case 'approve':
+ $message = 'USERS_APPROVED';
+ break;
+ }
- trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id));
+ trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id));
+ }
+ else
+ {
+ trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id), E_USER_WARNING);
+ }
+
break;
case 'default':
diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php
index f66f45cd36..00d99d2f9a 100644
--- a/phpBB/includes/acp/acp_icons.php
+++ b/phpBB/includes/acp/acp_icons.php
@@ -436,7 +436,7 @@ class acp_icons
default:
$suc_lang = $lang;
}
- $errormsgs = '<br />';
+ $errormsgs = '';
foreach ($errors as $img => $error)
{
$errormsgs .= '<br />' . sprintf($user->lang[$error], $img);
@@ -447,7 +447,7 @@ class acp_icons
}
else
{
- trigger_error($user->lang[$suc_lang . '_ADDED'] . $errormsgs .adm_back_link($this->u_action), $level);
+ trigger_error($user->lang[$suc_lang . '_ADDED'] . $errormsgs . adm_back_link($this->u_action), $level);
}
break;
diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php
index 5683ae5dab..5683ae5dab 100755..100644
--- a/phpBB/includes/acp/acp_inactive.php
+++ b/phpBB/includes/acp/acp_inactive.php
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php
index be337a20f3..7498ab2aef 100644
--- a/phpBB/includes/acp/acp_main.php
+++ b/phpBB/includes/acp/acp_main.php
@@ -61,6 +61,14 @@ class acp_main
if ($action)
{
+ if ($action === 'admlogout')
+ {
+ $user->unset_admin();
+ $redirect_url = append_sid("{$phpbb_root_path}index.$phpEx");
+ meta_refresh(3, $redirect_url);
+ trigger_error($user->lang['ADM_LOGGED_OUT'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect_url . '">', '</a>'));
+ }
+
if (!confirm_box(true))
{
switch ($action)
@@ -108,6 +116,7 @@ class acp_main
{
switch ($action)
{
+
case 'online':
if (!$auth->acl_get('a_board'))
{
diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php
index a9e64b74ae..9240db271c 100644
--- a/phpBB/includes/acp/acp_permissions.php
+++ b/phpBB/includes/acp/acp_permissions.php
@@ -1156,7 +1156,7 @@ class acp_permissions
}
// Not ideal, due to the filesort, non-use of indexes, etc.
- $sql = 'SELECT DISTINCT u.user_id, u.username
+ $sql = 'SELECT DISTINCT u.user_id, u.username, u.username_clean, u.user_regdate
FROM ' . USERS_TABLE . ' u, ' . ACL_USERS_TABLE . " a
WHERE u.user_id = a.user_id
$sql_forum_id
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index 88850d59b3..dd5255f755 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -695,6 +695,15 @@ parse_css_file = {PARSE_CSS_FILE}
{
trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
+
+ if ($save_changes && !check_form_key('acp_styles'))
+ {
+ trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
+ }
+ else if (!$save_changes)
+ {
+ add_form_key('acp_styles');
+ }
// save changes to the template if the user submitted any
if ($save_changes && $template_file)
diff --git a/phpBB/includes/acp/info/acp_inactive.php b/phpBB/includes/acp/info/acp_inactive.php
index e17fbda9dd..e17fbda9dd 100755..100644
--- a/phpBB/includes/acp/info/acp_inactive.php
+++ b/phpBB/includes/acp/info/acp_inactive.php
diff --git a/phpBB/includes/auth.php b/phpBB/includes/auth.php
index 8dd15fea64..d0b38b67a3 100644
--- a/phpBB/includes/auth.php
+++ b/phpBB/includes/auth.php
@@ -800,7 +800,7 @@ class auth
{
$this->_set_group_hold_ary($hold_ary[$row['forum_id']], $row['auth_option_id'], $row['auth_setting']);
}
- else
+ else if (!empty($this->role_cache[$row['auth_role_id']]))
{
foreach (unserialize($this->role_cache[$row['auth_role_id']]) as $option_id => $setting)
{
diff --git a/phpBB/includes/auth/auth_apache.php b/phpBB/includes/auth/auth_apache.php
index 4581a1bbdb..80ac81ed46 100644
--- a/phpBB/includes/auth/auth_apache.php
+++ b/phpBB/includes/auth/auth_apache.php
@@ -148,8 +148,8 @@ function autologin_apache()
if (!empty($php_auth_user) && !empty($php_auth_pw))
{
- set_var($php_auth_user, $php_auth_user, 'string');
- set_var($php_auth_pw, $php_auth_pw, 'string');
+ set_var($php_auth_user, $php_auth_user, 'string', true);
+ set_var($php_auth_pw, $php_auth_pw, 'string', true);
$sql = 'SELECT *
FROM ' . USERS_TABLE . "
@@ -233,7 +233,7 @@ function validate_session_apache(&$user)
}
$php_auth_user = '';
- set_var($php_auth_user, $_SERVER['PHP_AUTH_USER'], 'string');
+ set_var($php_auth_user, $_SERVER['PHP_AUTH_USER'], 'string', true);
return ($php_auth_user === $user['username']) ? true : false;
}
diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php
index eb4eb77f22..7c681a4040 100644
--- a/phpBB/includes/constants.php
+++ b/phpBB/includes/constants.php
@@ -171,6 +171,11 @@ define('FIELD_BOOL', 4);
define('FIELD_DROPDOWN', 5);
define('FIELD_DATE', 6);
+// referer validation
+define('REFERER_VALIDATE_NONE', 0);
+define('REFERER_VALIDATE_HOST', 1);
+define('REFERER_VALIDATE_PATH', 2);
+
// Additional constants
define('VOTE_CONVERTED', 127);
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 1baa7abd9a..40eb3fa823 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -255,7 +255,7 @@ function still_on_time($extra_time = 15)
/**
*
-* @version Version 0.1 / $Id$
+* @version Version 0.1 / slightly modified for phpBB 3.0.x (using $H$ as hash type identifier)
*
* Portable PHP password hashing framework.
*
@@ -1778,7 +1778,7 @@ function generate_board_url($without_script_path = false)
if ($server_port && (($config['cookie_secure'] && $server_port <> 443) || (!$config['cookie_secure'] && $server_port <> 80)))
{
- // HTTP HOST can carry a port number...
+ // HTTP HOST can carry a port number (we fetch $user->host, but for old versions this may be true)
if (strpos($server_name, ':') === false)
{
$url .= ':' . $server_port;
@@ -1801,6 +1801,7 @@ function generate_board_url($without_script_path = false)
/**
* Redirects the user to another page then exits the script nicely
+* This function is intended for urls within the board. It's not meant to redirect to cross-domains.
*/
function redirect($url, $return = false)
{
@@ -1829,7 +1830,11 @@ function redirect($url, $return = false)
}
else if (!empty($url_parts['scheme']) && !empty($url_parts['host']))
{
- // Full URL
+ // Attention: only able to redirect within the same domain (yourdomain.com -> www.yourdomain.com will not work)
+ if ($url_parts['host'] !== $user->host)
+ {
+ $url = generate_board_url();
+ }
}
else if ($url[0] == '/')
{
@@ -2045,11 +2050,14 @@ function meta_refresh($time, $url)
global $template;
$url = redirect($url, true);
+ $url = str_replace('&', '&amp;', $url);
// For XHTML compatibility we change back & to &amp;
$template->assign_vars(array(
- 'META' => '<meta http-equiv="refresh" content="' . $time . ';url=' . str_replace('&', '&amp;', $url) . '" />')
+ 'META' => '<meta http-equiv="refresh" content="' . $time . ';url=' . $url . '" />')
);
+
+ return $url;
}
//Form validation
@@ -2331,7 +2339,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
return;
}
- meta_refresh(3, $redirect);
+ $redirect = meta_refresh(3, $redirect);
trigger_error($message . '<br /><br />' . sprintf($l_redirect, '<a href="' . $redirect . '">', '</a>'));
}
@@ -2771,7 +2779,7 @@ function get_preg_expression($mode)
switch ($mode)
{
case 'email':
- return '(?:[a-z0-9\'\.\-_\+\|]|&amp;)+@[a-z0-9\-]+\.(?:[a-z0-9\-]+\.)*[a-z]+';
+ return '(?:[a-z0-9\'\.\-_\+\|]++|&amp;)+@[a-z0-9\-]+\.(?:[a-z0-9\-]+\.)*[a-z]+';
break;
case 'bbcode_htm':
@@ -2941,9 +2949,15 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
if (strpos($errfile, 'cache') === false && strpos($errfile, 'template.') === false)
{
// flush the content, else we get a white page if output buffering is on
+ if ((int) @ini_get('output_buffering') === 1 || strtolower(@ini_get('output_buffering')) === 'on')
+ {
+ @ob_flush();
+ }
+
+ // Another quick fix for those having gzip compression enabled, but do not flush if the coder wants to catch "something". ;)
if ($config['gzip_compress'])
{
- if (@extension_loaded('zlib') && !headers_sent())
+ if (@extension_loaded('zlib') && !headers_sent() && !ob_get_level())
{
@ob_flush();
}
@@ -3106,16 +3120,16 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
function obtain_guest_count($forum_id = 0)
{
global $db, $config;
-
+
if ($forum_id)
{
$reading_sql = ' AND s.session_forum_id = ' . (int) $forum_id;
- }
+ }
else
{
$reading_sql = '';
}
- $time = (time() - (intval($config['load_online_time']) * 60));
+ $time = (time() - (intval($config['load_online_time']) * 60));
// Get number of online guests
@@ -3141,7 +3155,7 @@ function obtain_guest_count($forum_id = 0)
$result = $db->sql_query($sql, 60);
$guests_online = (int) $db->sql_fetchfield('num_guests');
$db->sql_freeresult($result);
-
+
return $guests_online;
}
@@ -3173,16 +3187,16 @@ function obtain_users_online($forum_id = 0)
{
$online_users['guests_online'] = obtain_guest_count($forum_id);
}
-
+
// a little discrete magic to cache this for 30 seconds
- $time = (time() - (intval($config['load_online_time']) * 60));
+ $time = (time() - (intval($config['load_online_time']) * 60));
$sql = 'SELECT s.session_user_id, s.session_ip, s.session_viewonline
FROM ' . SESSIONS_TABLE . ' s
WHERE s.session_time >= ' . ($time - ((int) ($time % 30))) .
$reading_sql .
' AND s.session_user_id <> ' . ANONYMOUS;
- $result = $db->sql_query($sql, 30);
+ $result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
@@ -3203,7 +3217,7 @@ function obtain_users_online($forum_id = 0)
}
$online_users['total_online'] = $online_users['guests_online'] + $online_users['visible_online'] + $online_users['hidden_online'];
$db->sql_freeresult($result);
-
+
return $online_users;
}
@@ -3652,7 +3666,7 @@ function garbage_collection()
*/
function exit_handler()
{
- global $phpbb_hook;
+ global $phpbb_hook, $config;
if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__))
{
@@ -3663,7 +3677,7 @@ function exit_handler()
}
// As a pre-caution... some setups display a blank page if the flush() is not there.
- @flush();
+ (!$config['gzip_compress']) ? @flush() : @ob_flush();
exit;
}
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index afaf165d66..028456c246 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -1545,7 +1545,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
$sql = 'SELECT SUM(t.topic_replies + 1) AS forum_posts
FROM ' . TOPICS_TABLE . ' t
WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . '
- AND t.topic_approved = 1';
+ AND t.topic_approved = 1
+ AND t.topic_status <> ' . ITEM_MOVED;
}
else
{
@@ -1553,6 +1554,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
FROM ' . TOPICS_TABLE . ' t
WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . '
AND t.topic_approved = 1
+ AND t.topic_status <> ' . ITEM_MOVED . '
GROUP BY t.forum_id';
}
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index 36b7d575d9..021079deef 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -179,7 +179,7 @@ class compress_zip extends compress
* Extract archive
*/
function extract($dst)
- {
+ {
// Loop the file, looking for files and folders
$dd_try = false;
rewind($this->fp);
@@ -215,6 +215,12 @@ class compress_zip extends compress
// Create and folders and subfolders if they do not exist
foreach ($folders as $folder)
{
+ $folder = trim($folder);
+ if (!$folder)
+ {
+ continue;
+ }
+
$str = (!empty($str)) ? $str . '/' . $folder : $folder;
if (!is_dir($str))
{
@@ -231,13 +237,19 @@ class compress_zip extends compress
}
else
{
- // Some archivers are punks, they don't don't include folders in their archives!
+ // Some archivers are punks, they don't include folders in their archives!
$str = '';
$folders = explode('/', pathinfo($target_filename, PATHINFO_DIRNAME));
// Create and folders and subfolders if they do not exist
foreach ($folders as $folder)
{
+ $folder = trim($folder);
+ if (!$folder)
+ {
+ continue;
+ }
+
$str = (!empty($str)) ? $str . '/' . $folder : $folder;
if (!is_dir($str))
{
@@ -267,7 +279,7 @@ class compress_zip extends compress
// Not compressed
fwrite($fp, $content);
break;
-
+
case 8:
// Deflate
fwrite($fp, gzinflate($content, $data['uc_size']));
@@ -278,7 +290,7 @@ class compress_zip extends compress
fwrite($fp, bzdecompress($content));
break;
}
-
+
fclose($fp);
break;
@@ -288,11 +300,11 @@ class compress_zip extends compress
// This case should simply never happen.. but it does exist..
case "\x50\x4b\x05\x06":
break 2;
-
+
// 'Packed to Removable Disk', ignore it and look for the next signature...
case 'PK00':
continue 2;
-
+
// We have encountered a header that is weird. Lets look for better data...
default:
if (!$dd_try)
@@ -507,16 +519,24 @@ class compress_tar extends compress
$tmp = unpack('A12size', substr($buffer, 124, 12));
$filesize = octdec((int) trim($tmp['size']));
+ $target_filename = "$dst$filename";
+
if ($filetype == 5)
{
- if (!is_dir("$dst$filename"))
+ if (!is_dir($target_filename))
{
$str = '';
- $folders = explode('/', "$dst$filename");
+ $folders = explode('/', $target_filename);
// Create and folders and subfolders if they do not exist
foreach ($folders as $folder)
{
+ $folder = trim($folder);
+ if (!$folder)
+ {
+ continue;
+ }
+
$str = (!empty($str)) ? $str . '/' . $folder : $folder;
if (!is_dir($str))
{
@@ -529,17 +549,41 @@ class compress_tar extends compress
}
}
}
- else if ($filesize != 0 && ($filetype == 0 || $filetype == "\0"))
+ else if ($filesize >= 0 && ($filetype == 0 || $filetype == "\0"))
{
+ // Some archivers are punks, they don't properly order the folders in their archives!
+ $str = '';
+ $folders = explode('/', pathinfo($target_filename, PATHINFO_DIRNAME));
+
+ // Create and folders and subfolders if they do not exist
+ foreach ($folders as $folder)
+ {
+ $folder = trim($folder);
+ if (!$folder)
+ {
+ continue;
+ }
+
+ $str = (!empty($str)) ? $str . '/' . $folder : $folder;
+ if (!is_dir($str))
+ {
+ if (!@mkdir($str, 0777))
+ {
+ trigger_error("Could not create directory $folder");
+ }
+ @chmod($str, 0777);
+ }
+ }
+
// Write out the files
- if (!($fp = fopen("$dst$filename", 'wb')))
+ if (!($fp = fopen($target_filename, 'wb')))
{
trigger_error("Couldn't create file $filename");
}
- @chmod("$dst$filename", 0777);
+ @chmod($target_filename, 0777);
// Grab the file contents
- fwrite($fp, $fzread($this->fp, ($filesize + 511) &~ 511), $filesize);
+ fwrite($fp, ($filesize) ? $fzread($this->fp, ($filesize + 511) &~ 511) : '', $filesize);
fclose($fp);
}
}
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index 9eab477a8a..97ec78abcc 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -438,6 +438,7 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb
global $phpbb_root_path, $phpEx;
$uid = $bitfield = '';
+ $flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0);
if (!$text)
{
@@ -461,7 +462,6 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb
$uid = '';
}
- $flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0);
$bitfield = $message_parser->bbcode_bitfield;
return;
@@ -568,13 +568,13 @@ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class
$relative_url = preg_replace('/[&?]sid=[0-9a-f]{32}$/', '', preg_replace('/([&?])sid=[0-9a-f]{32}&/', '$1', $relative_url));
$url = $url . '/' . $relative_url;
$text = $relative_url;
-
+
// this url goes to http://domain.tld/path/to/board/ which
// would result in an empty link if treated as local so
// don't touch it and let MAGIC_URL_FULL take care of it.
if (!$relative_url)
{
- return $orig_url . '/'; // slash is taken away by relative url pattern
+ return $whitespace . $orig_url . '/'; // slash is taken away by relative url pattern
}
break;
diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php
index f43ef7c5c7..90459813f1 100644
--- a/phpBB/includes/functions_install.php
+++ b/phpBB/includes/functions_install.php
@@ -286,7 +286,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
{
case 'mysql':
case 'mysqli':
- if (strpos($table_prefix, '-') !== false || strpos($table_prefix, '.') !== false)
+ if (strspn($table_prefix, '-./\\') !== 0)
{
$error[] = $lang['INST_ERR_PREFIX_INVALID'];
return false;
diff --git a/phpBB/includes/functions_jabber.php b/phpBB/includes/functions_jabber.php
index 7633c10be9..6cae90d1c2 100644
--- a/phpBB/includes/functions_jabber.php
+++ b/phpBB/includes/functions_jabber.php
@@ -399,12 +399,13 @@ class jabber
$second_time = isset($this->session['id']);
$this->session['id'] = $xml['stream:stream'][0]['@']['id'];
+ /** Currently commented out due to problems with some jabber server - reason unknown
if ($second_time)
{
// If we are here for the second time after TLS, we need to continue logging in
$this->login();
return;
- }
+ }*/
// go on with authentication?
if (isset($this->features['stream:features'][0]['#']['bind']) || !empty($this->session['tls']))
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 2f12732e8b..fe41bc448d 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -358,6 +358,11 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx);
$upload = new fileupload();
+ if ($config['check_attachment_content'])
+ {
+ $upload->set_disallowed_content(explode('|', $config['mime_triggers']));
+ }
+
if (!$local)
{
$filedata['post_attach'] = ($upload->is_valid($form_name)) ? true : false;
@@ -524,6 +529,8 @@ function get_supported_image_types($type = false)
if ($type !== false)
{
+ // Type is one of the IMAGETYPE constants - it is fetched from getimagesize()
+ // We do not use the constants here, because some were not available in PHP 4.3.x
switch ($type)
{
// GIF
@@ -545,8 +552,7 @@ function get_supported_image_types($type = false)
$new_type = ($format & IMG_PNG) ? IMG_PNG : false;
break;
- // BMP, WBMP
- case 6:
+ // WBMP
case 15:
$new_type = ($format & IMG_WBMP) ? IMG_WBMP : false;
break;
@@ -1856,6 +1862,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
'topic_last_poster_id' => (int) $user->data['user_id'],
'topic_last_poster_name' => (!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : ''),
'topic_last_poster_colour' => $user->data['user_colour'],
+ 'topic_last_post_subject' => (string) $subject,
);
}
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index bffa64158a..d01d89a7e3 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -208,6 +208,11 @@ function get_folder($user_id, $folder_id = false)
);
}
+ if ($folder_id !== false && !isset($folder[$folder_id]))
+ {
+ trigger_error('UNKNOWN_FOLDER');
+ }
+
return $folder;
}
@@ -1803,4 +1808,25 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
return true;
}
+/**
+* Set correct users max messages in PM folder.
+* If several group memberships define different amount of messages, the highest will be chosen.
+*/
+function set_user_message_limit()
+{
+ global $user, $db, $config;
+
+ // Get maximum about from user memberships - if it is 0, there is no limit set and we use the maximum value within the config.
+ $sql = 'SELECT MAX(g.group_message_limit) as max_message_limit
+ FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
+ WHERE ug.user_id = ' . $user->data['user_id'] . '
+ AND ug.user_pending = 0
+ AND ug.group_id = g.group_id';
+ $result = $db->sql_query($sql);
+ $message_limit = (int) $db->sql_fetchfield('max_message_limit');
+ $db->sql_freeresult($result);
+
+ $user->data['message_limit'] = (!$message_limit) ? $config['pm_max_msgs'] : $message_limit;
+}
+
?> \ No newline at end of file
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
index ca4f51c12f..a1374b8d54 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -228,6 +228,34 @@ class filespec
{
return @filesize($filename);
}
+
+
+ /**
+ * Check the first 256 bytes for forbidden content
+ */
+ function check_content($disallowed_content)
+ {
+ if (empty($disallowed_content))
+ {
+ return true;
+ }
+
+ $fp = @fopen($this->filename, 'rb');
+
+ if ($fp !== false)
+ {
+ $ie_mime_relevant = fread($fp, 256);
+ fclose($fp);
+ foreach ($disallowed_content as $forbidden)
+ {
+ if (stripos($ie_mime_relevant, '<' . $forbidden) !== false)
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
/**
* Move file to destination folder
@@ -257,7 +285,7 @@ class filespec
return false;
}
- $upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode')) ? 'move' : 'copy';
+ $upload_mode = (@ini_get('open_basedir') || @ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'on') ? 'move' : 'copy';
$upload_mode = ($this->local) ? 'local' : $upload_mode;
$this->destination_file = $this->destination_path . '/' . basename($this->realname);
@@ -427,6 +455,7 @@ class fileerror extends filespec
class fileupload
{
var $allowed_extensions = array();
+ var $disallowed_content = array();
var $max_filesize = 0;
var $min_width = 0;
var $min_height = 0;
@@ -446,12 +475,13 @@ class fileupload
* @param int $max_height Maximum image height (only checked for images)
*
*/
- function fileupload($error_prefix = '', $allowed_extensions = false, $max_filesize = false, $min_width = false, $min_height = false, $max_width = false, $max_height = false)
+ function fileupload($error_prefix = '', $allowed_extensions = false, $max_filesize = false, $min_width = false, $min_height = false, $max_width = false, $max_height = false, $disallowed_content = false)
{
$this->set_allowed_extensions($allowed_extensions);
$this->set_max_filesize($max_filesize);
$this->set_allowed_dimensions($min_width, $min_height, $max_width, $max_height);
$this->set_error_prefix($error_prefix);
+ $this->set_disallowed_content($disallowed_content);
}
/**
@@ -463,6 +493,7 @@ class fileupload
$this->min_width = $this->min_height = $this->max_width = $this->max_height = 0;
$this->error_prefix = '';
$this->allowed_extensions = array();
+ $this->disallowed_content = array();
}
/**
@@ -497,6 +528,17 @@ class fileupload
$this->max_filesize = (int) $max_filesize;
}
}
+
+ /**
+ * Set disallowed strings
+ */
+ function set_disallowed_content($disallowed_content)
+ {
+ if ($disallowed_content !== false && is_array($disallowed_content))
+ {
+ $this->disallowed_content = $disallowed_content;
+ }
+ }
/**
* Set error prefix
@@ -741,7 +783,7 @@ class fileupload
return $file;
}
- $tmp_path = (!@ini_get('safe_mode')) ? false : $phpbb_root_path . 'cache';
+ $tmp_path = (!@ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'off') ? false : $phpbb_root_path . 'cache';
$filename = tempnam($tmp_path, unique_id() . '-');
if (!($fp = @fopen($filename, 'wb')))
@@ -830,6 +872,12 @@ class fileupload
{
$file->error[] = sprintf($user->lang[$this->error_prefix . 'DISALLOWED_EXTENSION'], $file->get('extension'));
}
+
+ // MIME Sniffing
+ if (!$this->valid_content($file))
+ {
+ $file->error[] = sprintf($user->lang[$this->error_prefix . 'DISALLOWED_CONTENT']);
+ }
}
/**
@@ -869,6 +917,15 @@ class fileupload
return (isset($_FILES[$form_name]) && $_FILES[$form_name]['name'] != 'none') ? true : false;
}
+
+ /**
+ * Check for allowed extension
+ */
+ function valid_content(&$file)
+ {
+ return ($file->check_content($this->disallowed_content));
+ }
+
/**
* Return image type/extension mapping
*/
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 1d1a24389c..daa571a790 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -183,7 +183,6 @@ function user_add($user_row, $cp_data = false)
'user_dateformat' => $config['default_dateformat'],
'user_lang' => $config['default_lang'],
'user_style' => (int) $config['default_style'],
- 'user_allow_pm' => 1,
'user_actkey' => '',
'user_ip' => '',
'user_regdate' => time(),
@@ -486,7 +485,7 @@ function user_delete($mode, $user_id, $post_username = false)
break;
}
- $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);
+ $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);
foreach ($table_ary as $table)
{
@@ -1195,6 +1194,8 @@ function user_ipwhois($ip)
*/
function validate_data($data, $val_ary)
{
+ global $user;
+
$error = array();
foreach ($val_ary as $var => $val_seq)
@@ -1211,7 +1212,8 @@ function validate_data($data, $val_ary)
if ($result = call_user_func_array('validate_' . $function, $validate))
{
- $error[] = $result . '_' . strtoupper($var);
+ // Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted.
+ $error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var);
}
}
}
@@ -1611,9 +1613,9 @@ function validate_email($email, $allowed_email = false)
}
}
- if ($user->check_ban(false, false, $email, true) == true)
+ if (($ban_reason = $user->check_ban(false, false, $email, true)) !== false)
{
- return 'EMAIL_BANNED';
+ return ($ban_reason === true) ? 'EMAIL_BANNED' : $ban_reason;
}
if (!$config['allow_emailreuse'])
@@ -1953,7 +1955,7 @@ function avatar_upload($data, &$error)
// Init upload class
include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx);
- $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $config['avatar_filesize'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height']);
+ $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $config['avatar_filesize'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], explode('|', $config['mime_triggers']));
if (!empty($_FILES['uploadfile']['name']))
{
@@ -2909,7 +2911,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
if (!sizeof($user_id_ary) || $result !== false)
{
- return false;
+ return 'NO_USERS';
}
if (!$group_name)
@@ -2921,9 +2923,23 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
{
case 'demote':
case 'promote':
+
+ $sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . "
+ WHERE group_id = $group_id
+ AND user_pending = 1
+ AND " . $db->sql_in_set('user_id', $user_id_ary);
+ $result = $db->sql_query_limit($sql, 1);
+ $not_empty = ($db->sql_fetchrow($result));
+ $db->sql_freeresult($result);
+ if ($not_empty)
+ {
+ return 'NO_VALID_USERS';
+ }
+
$sql = 'UPDATE ' . USER_GROUP_TABLE . '
SET group_leader = ' . (($action == 'promote') ? 1 : 0) . "
WHERE group_id = $group_id
+ AND user_pending = 0
AND " . $db->sql_in_set('user_id', $user_id_ary);
$db->sql_query($sql);
@@ -3017,7 +3033,7 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna
group_update_listings($group_id);
- return true;
+ return false;
}
/**
diff --git a/phpBB/includes/mcp/mcp_ban.php b/phpBB/includes/mcp/mcp_ban.php
index cb6211abda..d9f5eb8f22 100644
--- a/phpBB/includes/mcp/mcp_ban.php
+++ b/phpBB/includes/mcp/mcp_ban.php
@@ -151,7 +151,7 @@ class mcp_ban
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=mcp_ban&amp;field=ban'),
));
- if ($mode != 'user')
+ if ($mode === 'email' && !$auth->acl_get('a_user'))
{
return;
}
@@ -159,15 +159,28 @@ class mcp_ban
// As a "service" we will check if any post id is specified and populate the username of the poster id if given
$post_id = request_var('p', 0);
$user_id = request_var('u', 0);
- $username = false;
+ $username = $pre_fill = false;
if ($user_id && $user_id <> ANONYMOUS)
{
- $sql = 'SELECT username
+ $sql = 'SELECT username, user_email, user_ip
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
- $username = (string) $db->sql_fetchfield('username');
+ switch ($mode)
+ {
+ case 'user':
+ $pre_fill = (string) $db->sql_fetchfield('username');
+ break;
+
+ case 'ip':
+ $pre_fill = (string) $db->sql_fetchfield('user_ip');
+ break;
+
+ case 'email':
+ $pre_fill = (string) $db->sql_fetchfield('user_email');
+ break;
+ }
$db->sql_freeresult($result);
}
else if ($post_id)
@@ -176,13 +189,29 @@ class mcp_ban
if (sizeof($post_info) && !empty($post_info[$post_id]))
{
- $username = $post_info[$post_id]['username'];
+ switch ($mode)
+ {
+ case 'user':
+ $pre_fill = $post_info[$post_id]['username'];
+ break;
+
+ case 'ip':
+ $pre_fill = $post_info[$post_id]['poster_ip'];
+ break;
+
+ case 'email':
+ $pre_fill = $post_info[$post_id]['user_email'];
+ break;
+ }
+
}
}
- if ($username)
+ if ($pre_fill)
{
- $template->assign_var('USERNAMES', $username);
+ // left for legacy template compatibility
+ $template->assign_var('USERNAMES', $pre_fill);
+ $template->assign_var('BAN_QUANTIFIER', $pre_fill);
}
}
}
diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php
index 6c20cf85b4..6c20cf85b4 100755..100644
--- a/phpBB/includes/mcp/mcp_logs.php
+++ b/phpBB/includes/mcp/mcp_logs.php
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index 3332ab04d8..85f9a1e839 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -235,7 +235,7 @@ function lock_unlock($action, $ids)
}
unset($orig_ids);
- $redirect = request_var('redirect', build_url(array('_f_', 'action', 'quickmod')));
+ $redirect = request_var('redirect', build_url(array('action', 'quickmod')));
$s_hidden_fields = build_hidden_fields(array(
$sql_id . '_list' => $ids,
@@ -321,7 +321,7 @@ function change_topic_type($action, $topic_ids)
break;
}
- $redirect = request_var('redirect', build_url(array('_f_', 'action', 'quickmod')));
+ $redirect = request_var('redirect', build_url(array('action', 'quickmod')));
$s_hidden_fields = array(
'topic_id_list' => $topic_ids,
@@ -542,7 +542,7 @@ function mcp_move_topic($topic_ids)
}
$to_forum_id = request_var('to_forum_id', 0);
- $redirect = request_var('redirect', build_url(array('_f_', 'action', 'quickmod')));
+ $redirect = request_var('redirect', build_url(array('action', 'quickmod')));
$additional_msg = $success_msg = '';
$s_hidden_fields = build_hidden_fields(array(
@@ -554,7 +554,7 @@ function mcp_move_topic($topic_ids)
if ($to_forum_id)
{
- $forum_data = get_forum_data($to_forum_id);
+ $forum_data = get_forum_data($to_forum_id, 'f_post');
if (!sizeof($forum_data))
{
@@ -762,7 +762,7 @@ function mcp_delete_topic($topic_ids)
return;
}
- $redirect = request_var('redirect', build_url(array('_f_', 'action', 'quickmod')));
+ $redirect = request_var('redirect', build_url(array('action', 'quickmod')));
$forum_id = request_var('f', 0);
$s_hidden_fields = build_hidden_fields(array(
@@ -818,7 +818,7 @@ function mcp_delete_post($post_ids)
return;
}
- $redirect = request_var('redirect', build_url(array('_f_', 'action', 'quickmod')));
+ $redirect = request_var('redirect', build_url(array('action', 'quickmod')));
$forum_id = request_var('f', 0);
$s_hidden_fields = build_hidden_fields(array(
@@ -941,7 +941,7 @@ function mcp_fork_topic($topic_ids)
$to_forum_id = request_var('to_forum_id', 0);
$forum_id = request_var('f', 0);
- $redirect = request_var('redirect', build_url(array('_f_', 'action', 'quickmod')));
+ $redirect = request_var('redirect', build_url(array('action', 'quickmod')));
$additional_msg = $success_msg = '';
$s_hidden_fields = build_hidden_fields(array(
@@ -953,7 +953,7 @@ function mcp_fork_topic($topic_ids)
if ($to_forum_id)
{
- $forum_data = get_forum_data($to_forum_id);
+ $forum_data = get_forum_data($to_forum_id, 'f_post');
if (!sizeof($topic_ids))
{
@@ -990,7 +990,7 @@ function mcp_fork_topic($topic_ids)
if (confirm_box(true))
{
- $topic_data = get_topic_data($topic_ids);
+ $topic_data = get_topic_data($topic_ids, 'f_post');
$total_posts = 0;
$new_topic_id_list = array();
diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php
index 42a64055ce..42a64055ce 100755..100644
--- a/phpBB/includes/mcp/mcp_notes.php
+++ b/phpBB/includes/mcp/mcp_notes.php
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index 6d7f9ffaba..ab09761378 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -74,7 +74,7 @@ class mcp_queue
$this->tpl_name = 'mcp_post';
- $user->add_lang('posting');
+ $user->add_lang(array('posting', 'viewtopic'));
$post_id = request_var('p', 0);
$topic_id = request_var('t', 0);
@@ -459,7 +459,7 @@ function approve_post($post_id_list, $id, $mode)
trigger_error('NOT_AUTHORISED');
}
- $redirect = request_var('redirect', build_url(array('_f_', 'quickmod')));
+ $redirect = request_var('redirect', build_url(array('quickmod')));
$success_msg = '';
$s_hidden_fields = build_hidden_fields(array(
@@ -758,7 +758,7 @@ function disapprove_post($post_id_list, $id, $mode)
trigger_error('NOT_AUTHORISED');
}
- $redirect = request_var('redirect', build_url(array('t', 'mode', '_f_', 'quickmod')) . "&amp;mode=$mode");
+ $redirect = request_var('redirect', build_url(array('t', 'mode', 'quickmod')) . "&amp;mode=$mode");
$reason = utf8_normalize_nfc(request_var('reason', '', true));
$reason_id = request_var('reason_id', 0);
$success_msg = $additional_msg = '';
diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php
index 9419a37ab8..ce55fec7df 100755..100644
--- a/phpBB/includes/mcp/mcp_reports.php
+++ b/phpBB/includes/mcp/mcp_reports.php
@@ -450,15 +450,15 @@ function close_report($report_id_list, $mode, $action)
if ($action == 'delete' && strpos($user->data['session_page'], 'mode=report_details') !== false)
{
- $redirect = request_var('redirect', build_url(array('mode', '_f_', 'r', 'quickmod')) . '&amp;mode=reports');
+ $redirect = request_var('redirect', build_url(array('mode', 'r', 'quickmod')) . '&amp;mode=reports');
}
else if ($action == 'close' && !request_var('r', 0))
{
- $redirect = request_var('redirect', build_url(array('mode', '_f_', 'p', 'quickmod')) . '&amp;mode=reports');
+ $redirect = request_var('redirect', build_url(array('mode', 'p', 'quickmod')) . '&amp;mode=reports');
}
else
{
- $redirect = request_var('redirect', build_url(array('_f_', 'quickmod')));
+ $redirect = request_var('redirect', build_url(array('quickmod')));
}
$success_msg = '';
$forum_ids = array();
diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php
index f8214e4f1b..a468712a25 100644
--- a/phpBB/includes/mcp/mcp_topic.php
+++ b/phpBB/includes/mcp/mcp_topic.php
@@ -386,7 +386,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
return;
}
- $redirect = request_var('redirect', build_url(array('_f_', 'quickmod')));
+ $redirect = request_var('redirect', build_url(array('quickmod')));
$s_hidden_fields = build_hidden_fields(array(
'i' => 'main',
@@ -550,7 +550,7 @@ function merge_posts($topic_id, $to_topic_id)
return;
}
- $redirect = request_var('redirect', build_url(array('_f_', 'quickmod')));
+ $redirect = request_var('redirect', build_url(array('quickmod')));
$s_hidden_fields = build_hidden_fields(array(
'i' => 'main',
diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php
index 315a2c1362..7c17de9f43 100755..100644
--- a/phpBB/includes/mcp/mcp_warn.php
+++ b/phpBB/includes/mcp/mcp_warn.php
@@ -170,7 +170,7 @@ class mcp_warn
'USERNAME' => $row['username'],
'USERNAME_COLOUR' => ($row['user_colour']) ? '#' . $row['user_colour'] : '',
'U_USER' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u=' . $row['user_id']),
-
+
'WARNING_TIME' => $user->format_date($row['user_last_warning']),
'WARNINGS' => $row['user_warnings'],
));
@@ -262,11 +262,11 @@ class mcp_warn
}
$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&amp;mode=user_notes&amp;u=$user_id");
meta_refresh(2, $redirect);
- trigger_error($user->lang['USER_WARNING_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
+ trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
}
// OK, they didn't submit a warning so lets build the page for them to do so
-
+
// We want to make the message available here as a reminder
// Parse the message and subject
$message = censor_text($user_row['post_text']);
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 674e13de49..6c12903999 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -346,6 +346,12 @@ class bbcode_firstpass extends bbcode
$in = trim($in);
$error = false;
+ // Do not allow 0-sizes generally being entered
+ if ($width <= 0 || $height <= 0)
+ {
+ return '[flash=' . $width . ',' . $height . ']' . $in . '[/flash]';
+ }
+
// Apply the same size checks on flash files as on images
if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width'])
{
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index 1cd28fc6d2..80724fb5c5 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -546,8 +546,8 @@ class fulltext_mysql extends search_backend
break;
case 't':
- $sql_sort_table = ($type == 'posts') ? TOPICS_TABLE . ' t, ' : '';
- $sql_sort_join = ($type == 'posts') ? ' AND t.topic_id = p.topic_id ' : '';
+ $sql_sort_table = ($type == 'posts' && !$firstpost_only) ? TOPICS_TABLE . ' t, ' : '';
+ $sql_sort_join = ($type == 'posts' && !$firstpost_only) ? ' AND t.topic_id = p.topic_id ' : '';
break;
case 'f':
diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php
index bfcb02f8e6..b0e95a1559 100755..100644
--- a/phpBB/includes/search/fulltext_native.php
+++ b/phpBB/includes/search/fulltext_native.php
@@ -813,8 +813,8 @@ class fulltext_native extends search_backend
break;
case 't':
- $sql_sort_table = ($type == 'posts') ? TOPICS_TABLE . ' t, ' : '';
- $sql_sort_join = ($type == 'posts') ? ' AND t.topic_id = p.topic_id ' : '';
+ $sql_sort_table = ($type == 'posts' && !$firstpost_only) ? TOPICS_TABLE . ' t, ' : '';
+ $sql_sort_join = ($type == 'posts' && !$firstpost_only) ? ' AND t.topic_id = p.topic_id ' : '';
break;
case 'f':
@@ -900,7 +900,7 @@ class fulltext_native extends search_backend
if ($type == 'posts')
{
$sql = "SELECT $select
- FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($topic_id || $firstpost_only) ? ', ' . TOPICS_TABLE . ' t' : '') . "
+ FROM " . $sql_sort_table . POSTS_TABLE . ' p' . (($firstpost_only) ? ', ' . TOPICS_TABLE . ' t' : '') . "
WHERE $sql_author
$sql_topic_id
$sql_firstpost
diff --git a/phpBB/includes/search/search.php b/phpBB/includes/search/search.php
index 32d7ed595f..32d7ed595f 100755..100644
--- a/phpBB/includes/search/search.php
+++ b/phpBB/includes/search/search.php
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index da54a6c512..8a3a16727e 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -68,7 +68,7 @@ class session
foreach ($args as $key => $argument)
{
- if (strpos($argument, 'sid=') === 0 || strpos($argument, '_f_=') === 0)
+ if (strpos($argument, 'sid=') === 0)
{
continue;
}
@@ -158,8 +158,16 @@ class session
$this->cookie_data = array('u' => 0, 'k' => '');
$this->update_session_page = $update_session_page;
$this->browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : '';
+ $this->referer = (!empty($_SERVER['HTTP_REFERER'])) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : '';
$this->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
$this->host = (!empty($_SERVER['HTTP_HOST'])) ? (string) strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
+
+ // Since HTTP_HOST may carry a port definition, we need to remove it here...
+ if (strpos($this->host, ':') !== false)
+ {
+ $this->host = substr($this->host, 0, strpos($this->host, ':'));
+ }
+
$this->page = $this->extract_current_page($phpbb_root_path);
// if the forwarded for header shall be checked we have to validate its contents
@@ -217,9 +225,9 @@ class session
// Load limit check (if applicable)
if ($config['limit_load'] || $config['limit_search_load'])
{
- if ($load = @file_get_contents('/proc/loadavg'))
+ if ((function_exists('sys_getloadavg') && $load = sys_getloadavg()) || ($load = explode(' ', @file_get_contents('/proc/loadavg'))))
{
- $this->load = array_slice(explode(' ', $load), 0, 1);
+ $this->load = array_slice($load, 0, 1);
$this->load = floatval($this->load[0]);
}
else
@@ -264,7 +272,18 @@ class session
$s_forwarded_for = ($config['forwarded_for_check']) ? substr($this->data['session_forwarded_for'], 0, 254) : '';
$u_forwarded_for = ($config['forwarded_for_check']) ? substr($this->forwarded_for, 0, 254) : '';
- if ($u_ip === $s_ip && $s_browser === $u_browser && $s_forwarded_for === $u_forwarded_for)
+ // referer checks
+ // The @ before $config['referer_validation'] suppresses notices present while running the updater
+ $check_referer_path = (@$config['referer_validation'] == REFERER_VALIDATE_PATH);
+ $referer_valid = true;
+
+ // we assume HEAD and TRACE to be foul play and thus only whitelist GET
+ if (@$config['referer_validation'] && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) !== 'get')
+ {
+ $referer_valid = $this->validate_referer($check_referer_path);
+ }
+
+ if ($u_ip === $s_ip && $s_browser === $u_browser && $s_forwarded_for === $u_forwarded_for && $referer_valid)
{
$session_expired = false;
@@ -343,7 +362,14 @@ class session
// Added logging temporarly to help debug bugs...
if (defined('DEBUG_EXTRA') && $this->data['user_id'] != ANONYMOUS)
{
- add_log('critical', 'LOG_IP_BROWSER_FORWARDED_CHECK', $u_ip, $s_ip, $u_browser, $s_browser, htmlspecialchars($u_forwarded_for), htmlspecialchars($s_forwarded_for));
+ if ($referer_valid)
+ {
+ add_log('critical', 'LOG_IP_BROWSER_FORWARDED_CHECK', $u_ip, $s_ip, $u_browser, $s_browser, htmlspecialchars($u_forwarded_for), htmlspecialchars($s_forwarded_for));
+ }
+ else
+ {
+ add_log('critical', 'LOG_REFERER_INVALID', $this->referer);
+ }
}
}
}
@@ -1101,7 +1127,7 @@ class session
trigger_error($message);
}
- return ($banned) ? true : false;
+ return ($banned && $ban_row['ban_give_reason']) ? $ban_row['ban_give_reason'] : $banned;
}
/**
@@ -1279,6 +1305,55 @@ class session
$this->set_login_key($user_id);
}
}
+
+
+ /**
+ * Check if the request originated from the same page.
+ * @param bool $check_script_path If true, the path will be checked as well
+ */
+ function validate_referer($check_script_path = false)
+ {
+ // no referer - nothing to validate, user's fault for turning it off (we only check on POST; so meta can't be the reason)
+ if (empty($this->referer) || empty($this->host) )
+ {
+ return true;
+ }
+
+ $host = htmlspecialchars($this->host);
+ $ref = substr($this->referer, strpos($this->referer, '://') + 3);
+
+ if (!(stripos($ref , $host) === 0))
+ {
+ return false;
+ }
+ else if ($check_script_path && rtrim($this->page['root_script_path'], '/') !== '')
+ {
+ $ref = substr($ref, strlen($host));
+ $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
+
+ if ($server_port !== 80 && $server_port !== 443 && stripos($ref, ":$server_port") === 0)
+ {
+ $ref = substr($ref, strlen(":$server_port"));
+ }
+
+ if (!(stripos(rtrim($ref, '/'), rtrim($this->page['root_script_path'], '/')) === 0))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+ function unset_admin()
+ {
+ global $db;
+ $sql = 'UPDATE ' . SESSIONS_TABLE . '
+ SET session_admin = 0
+ WHERE session_id = \'' . $db->sql_escape($this->session_id) . '\'';
+ $db->sql_query($sql);
+ }
}
diff --git a/phpBB/includes/ucp/ucp_confirm.php b/phpBB/includes/ucp/ucp_confirm.php
index 0f37c456fa..b91c88b7e8 100644
--- a/phpBB/includes/ucp/ucp_confirm.php
+++ b/phpBB/includes/ucp/ucp_confirm.php
@@ -73,7 +73,9 @@ class ucp_confirm
$captcha = new captcha();
$captcha->execute($row['code'], $row['seed']);
- exit;
+
+ garbage_collection();
+ exit_handler();
}
}
diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php
index 46b23efb54..b4ac0c11da 100644
--- a/phpBB/includes/ucp/ucp_pm.php
+++ b/phpBB/includes/ucp/ucp_pm.php
@@ -129,15 +129,7 @@ class ucp_pm
break;
case 'options':
- $sql = 'SELECT group_message_limit
- FROM ' . GROUPS_TABLE . '
- WHERE group_id = ' . $user->data['group_id'];
- $result = $db->sql_query($sql, 3600);
- $message_limit = (int) $db->sql_fetchfield('group_message_limit');
- $db->sql_freeresult($result);
-
- $user->data['message_limit'] = (!$message_limit) ? $config['pm_max_msgs'] : $message_limit;
-
+ set_user_message_limit();
get_folder($user->data['user_id']);
include($phpbb_root_path . 'includes/ucp/ucp_pm_options.' . $phpEx);
@@ -168,14 +160,7 @@ class ucp_pm
case 'view':
- $sql = 'SELECT group_message_limit
- FROM ' . GROUPS_TABLE . '
- WHERE group_id = ' . $user->data['group_id'];
- $result = $db->sql_query($sql, 3600);
- $message_limit = (int) $db->sql_fetchfield('group_message_limit');
- $db->sql_freeresult($result);
-
- $user->data['message_limit'] = (!$message_limit) ? $config['pm_max_msgs'] : $message_limit;
+ set_user_message_limit();
if ($folder_specified)
{
diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php
index af592e3612..6271639cd1 100644
--- a/phpBB/includes/ucp/ucp_pm_compose.php
+++ b/phpBB/includes/ucp/ucp_pm_compose.php
@@ -636,7 +636,6 @@ function compose_pm($id, $mode, $action)
'filename_data' => $message_parser->filename_data,
'address_list' => $address_list
);
- unset($message_parser);
// ((!$message_subject) ? $subject : $message_subject)
$msg_id = submit_pm($action, $subject, $pm_data);
@@ -770,7 +769,6 @@ function compose_pm($id, $mode, $action)
$attachment_data = $message_parser->attachment_data;
$filename_data = $message_parser->filename_data;
$message_text = $message_parser->message;
- unset($message_parser);
// MAIN PM PAGE BEGINS HERE
@@ -892,8 +890,8 @@ function compose_pm($id, $mode, $action)
// Build hidden address list
$s_hidden_address_field = build_address_field($address_list);
-
-
+
+
$bbcode_checked = (isset($enable_bbcode)) ? !$enable_bbcode : (($config['allow_bbcode'] && $auth->acl_get('u_pm_bbcode')) ? !$user->optionget('bbcode') : 1);
$smilies_checked = (isset($enable_smilies)) ? !$enable_smilies : (($config['allow_smilies'] && $auth->acl_get('u_pm_smilies')) ? !$user->optionget('smilies') : 1);
$urls_checked = (isset($enable_urls)) ? !$enable_urls : 0;
@@ -1114,7 +1112,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove
}
}
-/**
+/**
* Build the hidden field for the recipients. Needed, as the variable is not read via request_var.
*/
function build_address_field($address_list)
diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php
index e9c337519a..8c765b1e90 100644
--- a/phpBB/includes/ucp/ucp_pm_viewfolder.php
+++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php
@@ -493,7 +493,7 @@ function get_pm_from($folder_id, $folder, $user_id)
}
else
{
- $pm_count = $folder[$folder_id]['num_messages'];
+ $pm_count = (!empty($folder[$folder_id]['num_messages'])) ? $folder[$folder_id]['num_messages'] : 0;
$sql_limit_time = '';
}
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php
index b30f28aac9..8098176837 100644
--- a/phpBB/includes/utf/utf_tools.php
+++ b/phpBB/includes/utf/utf_tools.php
@@ -1840,7 +1840,7 @@ function utf8_clean_string($text)
/**
* A wrapper for htmlspecialchars($value, ENT_COMPAT, 'UTF-8')
*/
-function utf8_htmlspecialchars(&$value)
+function utf8_htmlspecialchars($value)
{
return htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
}