diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index d737fbb3a4..dc297632d2 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2158,10 +2158,12 @@ function meta_refresh($time, $url)
function generate_link_hash($link_name)
{
global $user;
+
if (!isset($user->data["hash_$link_name"]))
{
$user->data["hash_$link_name"] = substr(sha1($user->data['user_form_salt'] . $link_name), 0, 8);
}
+
return $user->data["hash_$link_name"];
}
@@ -2184,16 +2186,18 @@ function check_link_hash($token, $link_name)
function add_form_key($form_name)
{
global $config, $template, $user;
+
$now = time();
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
$token = sha1($now . $user->data['user_form_salt'] . $form_name . $token_sid);
$s_fields = build_hidden_fields(array(
- 'creation_time' => $now,
- 'form_token' => $token,
+ 'creation_time' => $now,
+ 'form_token' => $token,
));
+
$template->assign_vars(array(
- 'S_FORM_TOKEN' => $s_fields,
+ 'S_FORM_TOKEN' => $s_fields,
));
}
@@ -2219,23 +2223,26 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
$creation_time = abs(request_var('creation_time', 0));
$token = request_var('form_token', '');
- $diff = (time() - $creation_time);
+ $diff = time() - $creation_time;
- if (($diff <= $timespan) || $timespan === -1)
+ // If creation_time and the time() now is zero we can assume it was not a human doing this (the check for if ($diff)...
+ if ($diff && ($diff <= $timespan || $timespan === -1))
{
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
-
$key = sha1($creation_time . $user->data['user_form_salt'] . $form_name . $token_sid);
+
if ($key === $token)
{
return true;
}
}
}
+
if ($trigger)
{
trigger_error($user->lang['FORM_INVALID'] . $return_page);
}
+
return false;
}
@@ -3100,7 +3107,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
}
// 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 (!empty($config['gzip_compress']))
{
if (@extension_loaded('zlib') && !headers_sent() && !ob_get_level())
{
@@ -3734,7 +3741,7 @@ function exit_handler()
}
// As a pre-caution... some setups display a blank page if the flush() is not there.
- (!$config['gzip_compress']) ? @flush() : @ob_flush();
+ (empty($config['gzip_compress'])) ? @flush() : @ob_flush();
exit;
}
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index c3ba40b5a7..eb9daf48be 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -1013,7 +1013,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
$uid = request_var('uid', 0);
if ($uid != $user_id)
{
- $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
+ $redirect_url = append_sid("view$mode", "$u_url=$match_id&start=$start");
$message = $user->lang['ERR_UNWATCHING'] . '
' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '', '');
trigger_error($message);
}
diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php
index dce9cc57d6..943472e545 100644
--- a/phpBB/includes/ucp/ucp_groups.php
+++ b/phpBB/includes/ucp/ucp_groups.php
@@ -437,7 +437,7 @@ class ucp_groups
$group_name = $group_row['group_name'];
$group_type = $group_row['group_type'];
- $avatar_img = (!empty($group_row['group_avatar'])) ? get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR') : '
';
+ $avatar_img = (!empty($group_row['group_avatar'])) ? get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR') : '
';
$template->assign_vars(array(
'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name,