// Parse bbcode into HTML code
function parseubb($text) {
global $locale;
$text = preg_replace('#\[b\](.*?)\[/b\]#si', '\1', $text);
$text = preg_replace('#\[i\](.*?)\[/i\]#si', '\1', $text);
$text = preg_replace('#\[u\](.*?)\[/u\]#si', '\1', $text);
$text = preg_replace('#\[s\](.*?)\[/s\]#si', '\1', $text);
$text = preg_replace('#\[center\](.*?)\[/center\]#si', '
\1', $text);
$text = preg_replace('#\[url\]([\r\n\s]*)(http://|ftp://|https://|ftps://)([^\s\'\"\+\(\)]*?)([\r\n\s]*)\[/url\]#sie', "'', '', '\\2\\3').'\' target=\'_blank\' title=\''.str_replace('
', '', '\\2\\3').'\'>\\2\\3'", $text);
$text = preg_replace('#\[url\] ([\r\n]*)([^\s\'\"\+\(\)]*?)([\r\n]*) \[/url\]#sie', "'', '', '\\2').'\' target=\'_blank\' title=\''.str_replace('
', '', '\\2').'\'>\\2'", $text);
$text = preg_replace('#\[url=([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\"\+\(\)]*?)\](.*?)([\r\n]*)\[/url\]#sie', "'', '', '\\2\\3').'\' target=\'_blank\' title=\''.str_replace('
', '', '\\2\\3').'\'>\\4'", $text);
$text = preg_replace('#\[url=([\r\n]*)([^\s\'\"\+\(\)]*?)\](.*?)([\r\n]*)\[/url\]#sie', "'', '', '\\2').'\' target=\'_blank\' title=\''.str_replace('
', '', '\\2').'\'>\\3'", $text);
$text = preg_replace('#\[mail\]([\r\n]*)([^\s\'\";:\+]*?)([\r\n]*)\[/mail\]#si', '\2', $text);
$text = preg_replace('#\[mail=([\r\n]*)([^\s\'\";:\+]*?)\](.*?)([\r\n]*)\[/mail\]#si', '\2', $text);
$text = preg_replace('#\[small\](.*?)\[/small\]#si', '\1', $text);
$text = preg_replace('#\[color=(black|blue|brown|cyan|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|violet|white|yellow)\](.*?)\[/color\]#si', '\2', $text);
if (iMEMBER) $text = preg_replace('#\[hide\](.*?)\[/hide\]#si', '\1', $text);
else $text = preg_replace('#\[hide\](.*?)\[/hide\]#si', $locale['200'], $text);
$text = preg_replace('#\[size=(8|10|12|14|16|18|20)\](.*?)\[/size\]#si', '\2', $text);
$text = preg_replace('#\[flash width=([0-9]*?) height=([0-9]*?)\]([^\s\'\";:\+]*?)(\.swf)\[/flash\]#si', '', $text);
$text = preg_replace("#\[img\]((http|ftp|https|ftps)://)(.*?)(\.(jpg|jpeg|gif|png|JPG|JPEG|GIF|PNG))\[/img\]#sie","''",$text);
$qcount = substr_count($text, "[quote]"); $ccount = substr_count($text, "[code]");
for ($i=0;$i < $qcount;$i++) $text = preg_replace('#\[quote\](.*?)\[/quote\]#si', '\1
', $text);
for ($i=0;$i < $ccount;$i++) $text = preg_replace('#\[code\](.*?)\[/code\]#si', '\1
', $text);
$text = descript($text,false);
return $text;
}