function bbcode($text)
{
$text = stripslashes($text);
#$text = htmlspecialchars($text);
$text = preg_replace("/\[B\](.*)\[\/B\]/isU","<b>$1</b>", $text);
$text = preg_replace("/\[I\](.*)\[\/I\]/isU","<i>$1</i>", $text);
$text = preg_replace("/\[U\](.*)\[\/U\]/isU","<u>$1</u>", $text);
$text = preg_replace("/\[quote\](.*)\[\/quote\]/isU","\"$1\"", $text);
$text = preg_replace("/\[INDENT\](.*)\[\/INDENT\]/isU","<blockquote><p>$1</p></blockquote>", $text);
$text = preg_replace("/\[left\](.*)\[\/left\]/isU","<p align='left'>$1</p>", $text);
$text = preg_replace("/\[right\](.*)\[\/right\]/isU","<p align='right'>$1</p>", $text);
$text = preg_replace("/\[CENTER\](.*?)\[\/CENTER\]/isU","<center>$1</center>", $text);
$text = preg_replace("/\[url=(.*)\](.*)\[\/URL\]/isU", "<a href=$1 target=\"_blank\">$2</a>", $text);
$text = preg_replace("/\[URL\](.*)\[\/URL\]/isU", "<a href=$1 target=\"_blank\">$1</a>", $text);
$text = preg_replace("/\[urli=(.*)\](.*)\[\/URLI\]/isU", "<a href=$1 target=\"_blank\">$2</a>", $text);
$text = preg_replace("/\[URLI\](.*)\[\/URLI\]/isU", "<a href=$1>$1</a>", $text);
$text = preg_replace("/\[email=(.*)\](.*)\[\/email\]/isU", "<a href=mailto:$1>$2</a>", $text);
$text = preg_replace("/\[EMAIL\](.*)\[\/EMAIL\]/isU", "<a href=mailto:$1>$1</a>", $text);
#$text = preg_replace("/\[url=(.*)\](.*)\[\/URL\]/isU", "<a href=\"$1\" target=\"_blank\">$2</a>", $text);
#$text = preg_replace("/\[URL\](.*)\[\/URL\]/isU", "<a href=\"$1\" target=\"_blank\">$1</a>", $text);
#$text = preg_replace("/\[email=(.*)\](.*)\[\/email\]/isU", "<a href=\"mailto:$1\">$2</a>", $text);
#$text = preg_replace("/\[EMAIL\](.*)\[\/EMAIL\]/isU", "<a href=\"mailto:$1\">$1</a>", $text);
$text = preg_replace("/\[img\](.*)\[\/img\]/isU", "<img src=\"$1\" />", $text);
$text = preg_replace("/\[code\](.*)\[\/code\]/isU", "<pre>$1</pre>", $text);
$text = eregi_replace("\\[color=([^\\[]*)\\]([^\\[]*)\\[\/color\\]","<font color=\\1>\\2</font>",$text);
$text = eregi_replace("\\[font=([^\\[]*)\\]([^\\[]*)\\[\/font\\]","<font face=\\1>\\2</font>",$text);
$text = eregi_replace("\\[size=([^\\[]*)\\]([^\\[]*)\\[\/size\\]","<font size=\\1>\\2</font>",$text);
#$text = preg_replace("/\[COLOR=(.*)\](.*)\[\/COLOR\]/isU", "<font color=\"$1\">$2</font>", $text);
#$text = preg_replace("/\[SIZE=(.*)\](.*)\[\/SIZE\]/isU", "<font size=\"$1\">$2</font>", $text);
#$text = preg_replace("/\[font=(.*)\](.*)\[\/FONT\]/isU", "<font face=\"$1\">$2</font>", $text);
$text = preg_replace("/\[list=(.*)\](.*)\[\/LIST\]/isU", "<ol start=\"1\" type=\"$1\">$2</ol>", $text);
$text = preg_replace("/\[list\](.*)\](.*)\[\/LIST\]/isU", "<ul><li>$2</ul>", $text);
$text = preg_replace("/\[\*\](.*)/isU", "<li>$1", $text);
$text = nl2br($text);
return $text;
}