function bbcode2html($message, $parseurl = 0) { if (empty($this->search_exp)) { $this->search_exp = array("/\\s*\\[quote\\][\n\r]*(.+?)[\n\r]*\\[\\/quote\\]\\s*/is", "/\\[url\\]\\s*(https?:\\/\\/|ftp:\\/\\/|gopher:\\/\\/|news:\\/\\/|telnet:\\/\\/|rtsp:\\/\\/|mms:\\/\\/|callto:\\/\\/|ed2k:\\/\\/){1}([^\\[\"']+?)\\s*\\[\\/url\\]/i", "/\\[em:(.+?):\\]/i"); $this->replace_exp = array("<div class=\"quote\"><blockquote>\\1</blockquote></div>", "<a href=\"\\1\\2\" target=\"_blank\">\\1\\2</a>", " <img src=\"" . STATICURL . "image/smiley/comcom/\\1.gif\" class=\"vm\"> "); $this->search_str = array('[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]'); $this->replace_str = array('<b>', '</b>', '<i>', '</i>', '<u>', '</u>'); } if ($parseurl == 2) { $this->search_exp[] = "/\\[img\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/ies"; $this->replace_exp[] = '$this->bb_img(\'\\1\')'; $message = bbcode::parseurl($message); } @($message = str_replace($this->search_str, $this->replace_str, preg_replace($this->search_exp, $this->replace_exp, $message, 20))); return nl2br(str_replace(array("\t", ' ', ' '), array(' ', ' ', ' '), $message)); }