function parseubb($text, $img=true) {
$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('#\[center\](.*?)\[/center\]#si', '
\1', $text);
$text = preg_replace('#\[url\]([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\";\+]*?)([\r\n]*)\[/url\]#si', '\2\3', $text);
$text = preg_replace('#\[url\]([\r\n]*)([^\s\'\";\+]*?)([\r\n]*)\[/url\]#si', '\2', $text);
$text = preg_replace('#\[url=([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\";\+]*?)\](.*?)([\r\n]*)\[/url\]#si', '\4', $text);
$text = preg_replace('#\[url=([\r\n]*)([^\s\'\";\+]*?)\](.*?)([\r\n]*)\[/url\]#si', '\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);
$text = preg_replace('#\[flash width=([0-9]*?) height=([0-9]*?)\]([^\s\'\";:\+]*?)(\.swf)\[/flash\]#si', '', $text);
if ($img) {
$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;
}