mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
- letting urls work again, fixing [code] breakage on urls, corrected magic_url to be able to parse urls at the beginning/end of bbcode blocks
- fixed "edited by" message. git-svn-id: file:///svn/phpbb/trunk@5027 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
d62c5a6fcd
commit
d4d1307e15
4 changed files with 57 additions and 62 deletions
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
'#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#',
|
||||
'#<!\-\- m \-\-><a href="(.*?)" target="_blank">.*?</a><!\-\- m \-\->#',
|
||||
|
@ -245,8 +246,8 @@ class bbcode_firstpass extends bbcode
|
|||
$code = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$str_from = array('<font color="syntax', '</font>', '<code>', '</code>','[', ']', '.');
|
||||
$str_to = array('<span class="syntax', '</span>', '', '', '[', ']', '.');
|
||||
$str_from = array('<font color="syntax', '</font>', '<code>', '</code>','[', ']', '.', ':');
|
||||
$str_to = array('<span class="syntax', '</span>', '', '', '[', ']', '.', ':');
|
||||
|
||||
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('#\<!-- (l|m|w|e) --\>.*?\<!-- \1 --\>#', $this->message, $matches);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse BBCode
|
||||
if ($allow_bbcode && strpos($this->message, '[') !== false)
|
||||
{
|
||||
|
@ -713,6 +703,17 @@ class parse_message extends bbcode_firstpass
|
|||
$num_urls += $this->parsed_items['url'];
|
||||
}
|
||||
|
||||
// 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('#\<!-- (l|m|w|e) --\>.*?\<!-- \1 --\>#', $this->message, $matches);
|
||||
}
|
||||
}
|
||||
|
||||
// Check number of links
|
||||
if ($config['max_' . $mode . '_urls'] && $num_urls > $config['max_' . $mode . '_urls'])
|
||||
{
|
||||
|
@ -817,10 +818,9 @@ class parse_message extends bbcode_firstpass
|
|||
|
||||
$server_port = ($server_port <> 80 ) ? ':' . trim($server_port) . '/' : '/';
|
||||
|
||||
$match = $replace = array();
|
||||
|
||||
if(!is_array($match))
|
||||
if (!is_array($match))
|
||||
{
|
||||
$match = $replace = array();
|
||||
// Be sure to not let the matches cross over. ;)
|
||||
|
||||
// relative urls for this board
|
||||
|
@ -839,6 +839,7 @@ class parse_message extends bbcode_firstpass
|
|||
$match[] = '#(^|[\n ]|\()([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)#ie';
|
||||
$replace[] = "'\$1<!-- e --><a href=\"mailto:\$2\">' . ((strlen('\$2') > 55) ? substr('\$2', 0, 39) . ' ... ' . substr('\$2', -10) : '\$2') . '</a><!-- e -->'";
|
||||
}
|
||||
|
||||
/* 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';
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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']) ? '<span style="color:#' . $user_edit_row['user_colour'] . '">' . $user_edit_row['username'] . '</span>' : $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']) ? '<span style="color:#' . $user_edit_row['user_colour'] . '">' . $user_edit_row['username'] . '</span>' : $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
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue