diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index d8f7c73790..1de7462768 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -109,12 +109,12 @@ class bbcode
{
continue;
}
- $bbcode_ids[] = $bbcode_id;
+ $bbcode_ids[$bbcode_id] = $bbcode_id;
// WARNING: hardcoded values. it assumes that bbcodes with bbcode_id > 11 are user-defined bbcodes
if ($bbcode_id > 11)
{
- $sql .= $bbcode_id . ',';
+ $sql .= (($sql) ? ',' : '') . $bbcode_id . ',';
}
}
/*
@@ -124,8 +124,8 @@ class bbcode
$rowset = array();
$sql = 'SELECT bbcode_id, second_pass_regexp, second_pass_replacement
- FROM ' . BBCODES_TABLE . '
- WHERE bbcode_id IN (' . substr($sql, 0, -1) . ')';
+ FROM ' . BBCODES_TABLE . "
+ WHERE bbcode_id IN ($sql);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -135,6 +135,7 @@ class bbcode
$db->sql_freeresult($result);
}
*/
+
foreach ($bbcode_ids as $bbcode_id)
{
switch ($bbcode_id)
@@ -142,126 +143,102 @@ class bbcode
case 0:
$this->bbcode_cache[$bbcode_id] = array(
'str' => array(
- '[quote:$uid]' => $this->bbcode_tpl('quote_open'),
- '[/quote:$uid]' => $this->bbcode_tpl('quote_close')
+ '[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')
+ '#\[quote="(.*?)":$uid\]#' => $this->bbcode_tpl('quote_username_open', $bbcode_id)
)
);
break;
case 1:
- $this->bbcode_cache[$bbcode_id] = array(
- 'str' => array(
- '[b:$uid]' => '',
- '[/b:$uid]' => ''
- )
- );
+ $this->bbcode_cache[$bbcode_id] = array('str' => array(
+ '[b:$uid]' => $this->bbcode_tpl('b_open', $bbcode_id),
+ '[/b:$uid]' => $this->bbcode_tpl('b_close', $bbcode_id)
+ ));
break;
case 2:
- $this->bbcode_cache[$bbcode_id] = array(
- 'str' => array(
- '[i:$uid]' => '',
- '[/i:$uid]' => ''
- )
- );
+ $this->bbcode_cache[$bbcode_id] = array('str' => array(
+ '[i:$uid]' => $this->bbcode_tpl('i_open', $bbcode_id),
+ '[/i:$uid]' => $this->bbcode_tpl('i_close', $bbcode_id)
+ ));
break;
case 3:
- $this->bbcode_cache[$bbcode_id] = array(
- 'preg' => array(
- '#\[url:$uid\](.*?)\[/url:$uid\]#s' => '\1',
- '#\[url=(.*?):$uid\](.*?)\[/url:$uid\]#s' => '\2'
- )
- );
+ $this->bbcode_cache[$bbcode_id] = array('preg' => array(
+ '#\[url:$uid\]((.*?))\[/url:$uid\]#s' => $this->bbcode_tpl('url', $bbcode_id),
+ '#\[url=([^\[]+?):$uid\](.*?)\[/url:$uid\]#s' => $this->bbcode_tpl('url', $bbcode_id)
+ ));
break;
case 4:
if ($user->data['user_viewimg'])
{
- $this->bbcode_cache[$bbcode_id] = array(
- 'preg' => array(
- '#\[img:$uid\](.*?)\[/img:$uid\]#s' => ''
- )
- );
+ $this->bbcode_cache[$bbcode_id] = array('preg' => array(
+ '#\[img:$uid\](.*?)\[/img:$uid\]#s' => $this->bbcode_tpl('img', $bbcode_id)
+ ));
}
else
{
- $this->bbcode_cache[$bbcode_id] = array(
- 'preg' => array(
- '#\[img:$uid\](.*?)\[/img:$uid\]#s' => '[ img ]'
- )
- );
+ $this->bbcode_cache[$bbcode_id] = array('preg' => array(
+ '#\[img:$uid\](.*?)\[/img:$uid\]#s' => str_replace('\\2', '[ img ]', $this->bbcode_tpl('url', $bbcode_id))
+ ));
}
- break;
+ break;
case 5:
- $this->bbcode_cache[$bbcode_id] = array(
- 'preg' => array(
- '#\[size=(.*?):$uid\](.*?)\[/size:$uid\]#s' => '\2'
- )
- );
+ $this->bbcode_cache[$bbcode_id] = array('preg' => array(
+ '#\[size=([\-\+]?[1-2]?[0-9]):$uid\](.*?)\[/size:$uid\]#s' => $this->bbcode_tpl('size', $bbcode_id)
+ ));
break;
case 6:
- $this->bbcode_cache[$bbcode_id] = array(
- 'preg' => array(
- '#\[color=(.*?):$uid\](.*?)\[/color:$uid\]#s' => '\2'
- )
- );
+ $this->bbcode_cache[$bbcode_id] = array('preg' => array(
+ '!\[color=(#[0-9A-F]{6}|[a-z\-]+):$uid\](.*?)\[/color:$uid\]!s' => $this->bbcode_tpl('color', $bbcode_id)
+ ));
break;
case 7:
- $this->bbcode_cache[$bbcode_id] = array(
- 'str' => array(
- '[u:$uid]' => '',
- '[/u:$uid]' => ''
- )
- );
+ $this->bbcode_cache[$bbcode_id] = array('str' => array(
+ '[u:$uid]' => $this->bbcode_tpl('u_open', $bbcode_id),
+ '[/u:$uid]' => $this->bbcode_tpl('u_close', $bbcode_id)
+ ));
break;
case 8:
- $this->bbcode_cache[$bbcode_id] = array(
- 'preg' => array(
- '#\[code(?:=([a-z]+))?:$uid\](.*?)\[/code:$uid\]#ise' => "\$this->bbcode_second_pass_code('\\1', '\\2')"
- )
- );
+ $this->bbcode_cache[$bbcode_id] = array('preg' => array(
+ '#\[code(?:=([a-z]+))?:$uid\](.*?)\[/code:$uid\]#ise' => "\$this->bbcode_second_pass_code('\\1', '\\2')"
+ ));
break;
case 9:
$this->bbcode_cache[$bbcode_id] = array(
'str' => array(
- '[list:$uid]' => '