function parseubb($text) {
$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\]#sie', "''.trimlink('\\2\\3', 20).(strlen('\\2\\3')>30?substr('\\2\\3', strlen('\\2\\3')-10, strlen('\\2\\3')):'').''", $text);
$text = preg_replace('#\[url\]([\r\n]*)([^\s\'\"\+\(\)]*?)([\r\n]*)\[/url\]#sie', "''.trimlink('\\2', 20).(strlen('\\2')>30?substr('\\2', strlen('\\2')-10, strlen('\\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);
[b]$text = preg_replace_callback("#\[img\]((http|ftp|https|ftps)://)(.*?)(\.(jpg|jpeg|gif|png|JPG|JPEG|GIF|PNG))\[/img\]#si","isImage",$text);[/b]
$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;
}