formatted = $this->bbcode_to_html($event->formatted); $event->stripped = $this->bbcode_to_text($event->stripped); } } private function bbcode_to_html($text) { $text = trim($text); $text = html_escape($text); $text = preg_replace("/\[b\](.*?)\[\/b\]/s", "\\1", $text); $text = preg_replace("/\[i\](.*?)\[\/i\]/s", "\\1", $text); $text = preg_replace("/\[u\](.*?)\[\/u\]/s", "\\1", $text); $text = preg_replace("/\[code\](.*?)\[\/code\]/s", "
\\1", $text); $text = preg_replace("/>>(\d+)/s", ">>\\1", $text); $text = preg_replace("/\[url=((?:https?|ftp|irc):\/\/.*?)\](.*?)\[\/url\]/s", "\\2", $text); $text = preg_replace("/\[url\]((?:https?|ftp|irc):\/\/.*?)\[\/url\]/s", "\\1", $text); $text = preg_replace("/\[\[(.*?)\]\]/s", "\\1", $text); $text = str_replace("\n", "\n