/**
* Parse BBCode
*/
function parse_bbcode()
{
if (!$this->bbcodes) {
$this->bbcode_init();
}
global $user;
$this->bbcode_bitfield = '';
$bitfield = new bitfield();
foreach ($this->bbcodes as $bbcode_name => $bbcode_data) {
if (isset($bbcode_data['disabled']) && $bbcode_data['disabled']) {
foreach ($bbcode_data['regexp'] as $regexp => $replacement) {
if (preg_match($regexp, $this->message)) {
$this->warn_msg[] = sprintf($user->lang['UNAUTHORISED_BBCODE'], '[' . $bbcode_name . ']');
continue;
}
}
} else {
foreach ($bbcode_data['regexp'] as $regexp => $replacement) {
// The pattern gets compiled and cached by the PCRE extension,
// it should not demand recompilation
if (preg_match($regexp, $this->message)) {
$this->message = preg_replace($regexp, $replacement, $this->message);
$bitfield->set($bbcode_data['bbcode_id']);
}
}
}
}
$this->bbcode_bitfield = $bitfield->get_base64();
}