[ticket/8796] Prevent setting post_time greater than time() in markread

PHPBB3-8796
This commit is contained in:
Nathan Guse 2012-09-30 10:29:43 -05:00
parent fccbf09e4a
commit 51862f151d

View file

@ -1291,7 +1291,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
global $db, $user, $config; global $db, $user, $config;
global $request; global $request;
$post_time = ($post_time === 0) ? time() : (int) $post_time; $post_time = ($post_time === 0 || $post_time > time()) ? time() : (int) $post_time;
if ($mode == 'all') if ($mode == 'all')
{ {
@ -2114,7 +2114,7 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam
$on_page = floor($start_item / $per_page) + 1; $on_page = floor($start_item / $per_page) + 1;
$url_delim = (strpos($base_url, '?') === false) ? '?' : ((strpos($base_url, '?') === strlen($base_url) - 1) ? '' : '&'); $url_delim = (strpos($base_url, '?') === false) ? '?' : ((strpos($base_url, '?') === strlen($base_url) - 1) ? '' : '&');
if ($reverse_count) if ($reverse_count)
{ {
$start_page = ($total_pages > 5) ? $total_pages - 4 : 1; $start_page = ($total_pages > 5) ? $total_pages - 4 : 1;
@ -2123,9 +2123,9 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam
else else
{ {
// What we're doing here is calculating what the "start" and "end" pages should be. We // What we're doing here is calculating what the "start" and "end" pages should be. We
// do this by assuming pagination is "centered" around the currently active page with // do this by assuming pagination is "centered" around the currently active page with
// the three previous and three next page links displayed. Anything more than that and // the three previous and three next page links displayed. Anything more than that and
// we display the ellipsis, likewise anything less. // we display the ellipsis, likewise anything less.
// //
// $start_page is the page at which we start creating the list. When we have five or less // $start_page is the page at which we start creating the list. When we have five or less
// pages we start at page 1 since there will be no ellipsis displayed. Anymore than that // pages we start at page 1 since there will be no ellipsis displayed. Anymore than that
@ -2144,18 +2144,18 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam
if ($on_page != $total_pages) if ($on_page != $total_pages)
{ {
$template->assign_block_vars($block_var_name, array( $template->assign_block_vars($block_var_name, array(
'PAGE_NUMBER' => '', 'PAGE_NUMBER' => '',
'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page), 'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page),
'S_IS_CURRENT' => false, 'S_IS_CURRENT' => false,
'S_IS_PREV' => false, 'S_IS_PREV' => false,
'S_IS_NEXT' => true, 'S_IS_NEXT' => true,
'S_IS_ELLIPSIS' => false, 'S_IS_ELLIPSIS' => false,
)); ));
} }
// This do...while exists purely to negate the need for start and end assign_block_vars, i.e. // This do...while exists purely to negate the need for start and end assign_block_vars, i.e.
// to display the first and last page in the list plus any ellipsis. We use this loop to jump // to display the first and last page in the list plus any ellipsis. We use this loop to jump
// around a little within the list depending on where we're starting (and ending). // around a little within the list depending on where we're starting (and ending).
$at_page = 1; $at_page = 1;
do do
{ {
@ -2166,17 +2166,17 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam
// of those points and of course do we even need to display it, i.e. is the list starting // of those points and of course do we even need to display it, i.e. is the list starting
// on at least page 3 and ending three pages before the final item. // on at least page 3 and ending three pages before the final item.
$template->assign_block_vars($block_var_name, array( $template->assign_block_vars($block_var_name, array(
'PAGE_NUMBER' => $at_page, 'PAGE_NUMBER' => $at_page,
'PAGE_URL' => $page_url, 'PAGE_URL' => $page_url,
'S_IS_CURRENT' => (!$ignore_on_page && $at_page == $on_page), 'S_IS_CURRENT' => (!$ignore_on_page && $at_page == $on_page),
'S_IS_NEXT' => false, 'S_IS_NEXT' => false,
'S_IS_PREV' => false, 'S_IS_PREV' => false,
'S_IS_ELLIPSIS' => ($at_page == 2 && $start_page > 2) || ($at_page == $total_pages - 1 && $end_page < $total_pages - 1), 'S_IS_ELLIPSIS' => ($at_page == 2 && $start_page > 2) || ($at_page == $total_pages - 1 && $end_page < $total_pages - 1),
)); ));
// We may need to jump around in the list depending on whether we have or need to display // We may need to jump around in the list depending on whether we have or need to display
// the ellipsis. Are we on page 2 and are we more than one page away from the start // the ellipsis. Are we on page 2 and are we more than one page away from the start
// of the list? Yes? Then we jump to the start of the list. Likewise are we at the end of // of the list? Yes? Then we jump to the start of the list. Likewise are we at the end of
// the list and are there more than two pages left in total? Yes? Then jump to the penultimate // the list and are there more than two pages left in total? Yes? Then jump to the penultimate
// page (so we can display the ellipsis next pass). Else, increment the counter and keep // page (so we can display the ellipsis next pass). Else, increment the counter and keep
// going // going
@ -2198,18 +2198,18 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam
if ($on_page != 1) if ($on_page != 1)
{ {
$template->assign_block_vars($block_var_name, array( $template->assign_block_vars($block_var_name, array(
'PAGE_NUMBER' => '', 'PAGE_NUMBER' => '',
'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . (($on_page - 2) * $per_page), 'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . (($on_page - 2) * $per_page),
'S_IS_CURRENT' => false, 'S_IS_CURRENT' => false,
'S_IS_PREV' => true, 'S_IS_PREV' => true,
'S_IS_NEXT' => false, 'S_IS_NEXT' => false,
'S_IS_ELLIPSIS' => false, 'S_IS_ELLIPSIS' => false,
)); ));
} }
} }
/** /**
* Return current page * Return current page
* This function also sets certain specific template variables * This function also sets certain specific template variables
* *
* @param object $template the template object * @param object $template the template object
@ -2229,9 +2229,9 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star
$template->assign_vars(array( $template->assign_vars(array(
'PER_PAGE' => $per_page, 'PER_PAGE' => $per_page,
'ON_PAGE' => $on_page, 'ON_PAGE' => $on_page,
'A_BASE_URL' => addslashes($base_url), 'A_BASE_URL' => addslashes($base_url),
)); ));
return sprintf($user->lang['PAGE_OF'], $on_page, max(ceil($num_items / $per_page), 1)); return sprintf($user->lang['PAGE_OF'], $on_page, max(ceil($num_items / $per_page), 1));
@ -3406,7 +3406,7 @@ function parse_cfg_file($filename, $lines = false)
$parsed_items[$key] = $value; $parsed_items[$key] = $value;
} }
if (isset($parsed_items['parent']) && isset($parsed_items['name']) && $parsed_items['parent'] == $parsed_items['name']) if (isset($parsed_items['parent']) && isset($parsed_items['name']) && $parsed_items['parent'] == $parsed_items['name'])
{ {
unset($parsed_items['parent']); unset($parsed_items['parent']);