diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 1e4183109d..e0b22fd140 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -163,11 +163,10 @@ class bbcode case 0: $this->bbcode_cache[$bbcode_id] = array( 'str' => array( - '[quote:$uid]' => $this->bbcode_tpl('quote_open', $bbcode_id), '[/quote:$uid]' => $this->bbcode_tpl('quote_close', $bbcode_id) ), 'preg' => array( - '#\[quote="(.*?)":$uid\]#' => $this->bbcode_tpl('quote_username_open', $bbcode_id) + '#\[quote(?:="(.*?)")?:$uid\](.)#ise' => "\$this->bbcode_second_pass_quote('\$1', '\$2')" ) ); break; @@ -459,6 +458,23 @@ class bbcode return str_replace('{LIST_TYPE}', $type, $this->bbcode_tpl($tpl)); } + function bbcode_second_pass_quote($username, $quote) + { + // when using the /e modifier, preg_replace slashes double-quotes but does not + // seem to slash anything else + $quote = str_replace('\"', '"', $quote); + + // remove newline at the beginning + if ($quote{0} == "\n") + { + $quote = substr($quote, 1); + } + + $quote = (($username) ? str_replace('$1', $username, $this->bbcode_tpl('quote_username_open')) : $this->bbcode_tpl('quote_open')) . $quote; + + return $quote; + } + function bbcode_second_pass_code($type, $code) { // when using the /e modifier, preg_replace slashes double-quotes but does not diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index bcbdd47234..02e8d685f3 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -181,6 +181,7 @@ class bbcode_firstpass extends bbcode // We remove the hardcoded elements from the code block here because it is not used in code blocks // Having it here saves us one preg_replace per message containing [code] blocks + // Additionally, magic url parsing should go after parsing bbcodes, but for safety those are stripped out too... $htm_match = array( '#.*?#', '#.*?#', @@ -245,8 +246,8 @@ class bbcode_firstpass extends bbcode $code = ob_get_contents(); ob_end_clean(); - $str_from = array('', '', '', '[', ']', '.'); + $str_from = array('', '', '', '[', ']', '.', ':'); if ($remove_tags) { @@ -271,8 +272,8 @@ class bbcode_firstpass extends bbcode break; default: - $str_from = array('<', '>', '[', ']', '.'); - $str_to = array('<', '>', '[', ']', '.'); + $str_from = array('<', '>', '[', ']', '.', ':'); + $str_to = array('<', '>', '[', ']', '.', ':'); $out .= '[code:' . $this->bbcode_uid . ']' . str_replace($str_from, $str_to, $code) . '[/code:' . $this->bbcode_uid . ']'; } @@ -412,8 +413,8 @@ class bbcode_firstpass extends bbcode $tok = ']'; $out = '['; - // Add newline at the end of each quote block to prevent parsing errors (urls, smilies, etc.) - $in = preg_replace('#([^\n])\[\/quote\]#is', "\\1\n[/quote]", $in); + // Add newline at the end and in front of each quote block to prevent parsing errors (urls, smilies, etc.) + $in = preg_replace(array('#\[quote(=?.*?)\]([^\n])#is', '#([^\n])\[\/quote\]#is'), array("[quote\\1]\n\\2", "\\1\n[/quote]"), $in); $in = substr(str_replace('\"', '"', $in), 1); $close_tags = $error_ary = array(); @@ -685,17 +686,6 @@ class parse_message extends bbcode_firstpass $num_urls = 0; - // Parse URL's - if ($allow_magic_url) - { - $this->magic_url((($config['cookie_secure']) ? 'https://' : 'http://'), $config['server_name'], $config['server_port'], $config['script_path']); - - if ($config['max_' . $mode . '_urls']) - { - $num_urls += preg_match_all('#\' . ((strlen('\$2') > 55) ? substr('\$2', 0, 39) . ' ... ' . substr('\$2', -10) : '\$2') . ''"; } + /* IMPORTANT NOTE (Developer inability to do advanced regular expressions) - Acyd Burn: Transforming < (<) to <&lt; in order to bypass the inability of preg_replace supporting multi-character sequences (POSIX - [..]). Since all message text is specialchared by @@ -860,7 +861,7 @@ class parse_message extends bbcode_firstpass // NOTE: There is a memory leak in this block somewhere :\ // See if the static arrays have already been filled on an earlier invocation - if(!is_array($match)) + if (!is_array($match)) { // NOTE: obtain_* function? chaching the table contents? @@ -902,7 +903,7 @@ class parse_message extends bbcode_firstpass $db->sql_freeresult($result); } - if(count($match)) + if (sizeof($match)) { if ($max_smilies) { @@ -1192,9 +1193,9 @@ class fulltext_search // NCRs like   etc. $match[] = '#(&|&)[\#a-z0-9]+?;#i'; // Do not index code - $match[] = '#\[code(=.*)?(\:?[0-9a-z]{5,})\].*?\[\/code(\:?[0-9a-z]{5,})\]#is'; + $match[] = '#\[code=?.*?(\:?[0-9a-z]{5,})\].*?\[\/code(\:?[0-9a-z]{5,})\]#is'; // BBcode - $match[] = '#\[\/?[a-z\*\+\-]+(=.*)?(\:?[0-9a-z]{5,})\]#'; + $match[] = '#\[\/?[a-z\*\+\-]+=?.*?(\:?[0-9a-z]{5,})\]#'; // Sequences > min_search_chars & < max_search_chars // $match[] = '#\s([\b]{1,' . $config['min_search_chars'] . '}|[\b]{' . $config['max_search_chars'] . ',})\s#is'; // $match[] = '#\s((&\#[0-9]+;){1,' . $config['min_search_chars'] . '}|(&\#[0-9]+;){' . $config['max_search_chars'] . ',})\s#is'; diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 95d9f52979..7b219f8490 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -476,37 +476,7 @@ if ($forum_data['forum_type'] == FORUM_POST || ($forum_data['forum_flags'] & 16) { $mark_forum_read = false; } -/* - if ($config['load_db_lastread']) - { - if ((isset($row['mark_time']) && $row['topic_last_post_time'] > $row['mark_time']) || (empty($row['mark_time']) && $row['topic_last_post_time'] > $forum_data['mark_time'])) - { - // sync post/topic marking - if (isset($unread_topc) && !$unread_topic && !empty($row['mark_time']) && $row['mark_time']) - { - markread('topic', $forum_id, $topic_id); - } - else - { - $mark_forum_read = false; - } - } - } - else - { - if (($mark_time_topic && $row['topic_last_post_time'] > $mark_time_topic) || (!$mark_time_topic && $mark_time_forum && $row['topic_last_post_time'] > $mark_time_forum)) - { - if (isset($unread_topic) && !$unread_topic && !empty($row['mark_time']) && $mark_time_topic) - { - markread('topic', $forum_id, $topic_id); - } - else - { - $mark_forum_read = false; - } - } - } -*/ + unset($rowset[$topic_id]); } } diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 87d34c192e..4698e9df40 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -194,7 +194,7 @@ if (!($topic_data = $db->sql_fetchrow($result))) // Extract the data extract($topic_data); -// We make this check here because the correct forum_id is determined +// $topic_replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_replies_real : $topic_replies; unset($topic_replies_real); @@ -232,12 +232,13 @@ else } // Check sticky/announcement time limit -if (($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) && $topic_time_limit && $topic_time + $topic_time_limit < time()) +if (($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) && $topic_time_limit && ($topic_time + $topic_time_limit) < time()) { $sql = 'UPDATE ' . TOPICS_TABLE . ' SET topic_type = ' . POST_NORMAL . ', topic_time_limit = 0 WHERE topic_id = ' . $topic_id; $db->sql_query($sql); + $topic_type = POST_NORMAL; $topic_time_limit = 0; } @@ -1188,11 +1189,18 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) unset($post_storage_list); } + $l_edit_time_total = ($row['post_edit_count'] == 1) ? $user->lang['EDITED_TIME_TOTAL'] : $user->lang['EDITED_TIMES_TOTAL']; - $user_edit_row = ($row['post_edit_reason']) ? $post_edit_list[$row['post_edit_user']] : array(); - - $l_edited_by = sprintf($l_edit_time_total, (!$row['post_edit_user']) ? $row['poster'] : (($user_edit_row['user_colour']) ? '' . $user_edit_row['username'] . '' : $user_edit_row['username']), $user->format_date($row['post_edit_time']), $row['post_edit_count']); + if ($row['post_edit_reason']) + { + $user_edit_row = $post_edit_list[$row['post_edit_user']]; + $l_edited_by = sprintf($l_edit_time_total, (!$row['post_edit_user']) ? $row['poster'] : (($user_edit_row['user_colour']) ? '' . $user_edit_row['username'] . '' : $user_edit_row['username']), $user->format_date($row['post_edit_time']), $row['post_edit_count']); + } + else + { + $l_edited_by = sprintf($l_edit_time_total, (!$row['post_edit_user']) ? $row['poster'] : $user_cache[$row['post_edit_user']]['username'], $user->format_date($row['post_edit_time']), $row['post_edit_count']); + } } else {