$mypn=mysql_fetch_object($mypnsql);
function parse_bbcode($str)
{
$str = preg_replace('#\<p\>(.*)\</p\>#isU', "[p]$1[/p]", $str);
$str = preg_replace('#\<h1\>(.*)\</h1\>#isU', "[h1]$1[/h1]", $str);
$str = preg_replace('#\<h2\>(.*)\</h2\>#isU', "[h2]$1[/h2]", $str);
# HTML Zeichen maskieren
$str = strip_tags($str);
# Formatierungen
$str = preg_replace('#\[p\](.*)\[/p\]#isU', "<p>$1</p>", $str);
$str = preg_replace('#\[h1\](.*)\[/h1\]#isU', "<h1>$1</h1><p>", $str);
$str = preg_replace('#\[h2\](.*)\[/h2\]#isU', "<h2>$1</h2><p>", $str);
$str = preg_replace('#\[b\](.*)\[/b\]#isU', "<b>$1</b>", $str);
$str = preg_replace('#\[i\](.*)\[/i\]#isU', "<i>$1</i>", $str);
$str = preg_replace('#\[u\](.*)\[/u\]#isU', "<u>$1</u>", $str);
$str = preg_replace('#\[color=(.*)\](.*)\[/color\]#isU', "<span style=\"color: $1\">$2</span>", $str);
$str = preg_replace('#\[size=(80|100|120)\](.*)\[/size\]#isU', "<span style=\"font-size: $1%\">$2</span>", $str);
# Links
$str = preg_replace('#\[url\](.*)\[/url\]#isU', "<a href=\"$1\">$1</a>", $str);
$str = preg_replace('#\[ url=(.*)\](.*)\[/url\]#isU', "<a href=\"$1\">$2</a>", $str);
# Grafiken
$str = preg_replace('#\[img\](.*)\[/img\]#isU', "<img src=\"$1\" alt=\"$1\" />", $str);
# Zitate
$str = preg_replace('#\[quote\](.*)\[/quote\]#isU', "<div class=\"zitat\">$1</div>", $str);
# Quelltext
$str = preg_replace('#\[code\](.*)\[/code\]#isU', "<div class=\"code\">$1</div>", $str);
# Listen
$str = preg_replace('#\[list\](.*)\[/list\]#isU', "<ul>$1</ul>", $str);
$str = preg_replace('#\[list=(1|a)\](.*)\[/list\]#isU', "<ol type=\"$1\">$2</ol>", $str);
$str = preg_replace("#\[*\](.*)\\r\\n#U", "<li>$1</li>", $str);
# Smilies
$str = str_replace(':)', '<img src="smile/smile.png" />', $str);
$str = str_replace(':*', '<img src="smile/kiss.png" />', $str);
$str = str_replace(':$', '<img src="smile/pouty.png" />', $str);
$str = str_replace(':kissing:', '<img src="smile/kissing.png" />', $str);
$str = str_replace(':(', '<img src="smile/sad.png" />', $str);
$str = str_replace(':-[', '<img src="smile/blush.png" />', $str);
$str = str_replace('=0', '<img src="smile/shocked.png" />', $str);
$str = str_replace(']8-', '<img src="smile/devil.png" />', $str);
$str = str_replace(';)', '<img src="smile/wink.png" />', $str);
$str = str_replace(':angel:', '<img src="smile/angel.png" />', $str);
$str = str_replace('8-)', '<img src="smile/cool.png" />', $str);
$str = str_replace(':rose:', '<img src="smile/rose.png" />', $str);
$str = str_replace(':P', '<img src="smile/tongue.png" />', $str);
$str = str_replace(':X', '<img src="smile/stfu.png" />', $str);
$str = str_replace(':music:', '<img src="smile/music.png" />', $str);
$str = str_replace('@=', '<img src="smile/bomb.png" />', $str);
$str = str_replace(':laughing:', '<img src="smile/laughing.png" />', $str);
$str = str_replace(':wrong:', '<img src="smile/wrong.png" />', $str);
$str = str_replace(':yawn:', '<img src="smile/yawn.png" />', $str);
$str = str_replace(':thumbs up:', '<img src="smile/thumbsup.png" />', $str);
$str = str_replace('(((', '<img src="smile/cry.png" />', $str);
$str = str_replace(':angry:', '<img src="smile/angry.png" />', $str);
$str = str_replace(':-!', '<img src="smile/sick.png" />', $str);
$str = str_replace(':beer:', '<img src="smile/beer.png" />', $str);
$str = str_replace(':kissed:', '<img src="smile/kissed.png" />', $str);
$str = str_replace(':D', '<img src="smile/biggrin.png" />', $str);
$str = str_replace(':stop:', '<img src="smile/stop.png" />', $str);
$str = str_replace(':inlove:', '<img src="smile/inlove.png" />', $str);
$str = str_replace('O_o', '<img src="smile/blink.png" />', $str);
$str = str_replace(':-r', '<img src="smile/drool.png" />', $str);
$str = str_replace(':getlost:', '<img src="smile/getlost.png" />', $str);
$str = str_replace(':grin:', '<img src="smile/grin.png" />', $str);
$str = str_replace('^^', '<img src="smile/happy.png" />', $str);
$str = str_replace(':poo:', '<img src="smile/poo.png" />', $str);
$str = str_replace(':rolleyes:', '<img src="smile/rolleyes.png" />', $str);
$str = str_replace('O_O', '<img src="smile/shock.png" />', $str);
$str = str_replace('=]', '<img src="smile/sideways.png" />', $str);
$str = str_replace('-_-', '<img src="smile/sleep.png" />', $str);
$str = str_replace(':-B', '<img src="smile/teeth.png" />', $str);
$str = str_replace(':thumb down:', '<img src="smile/thumbdown.png" />', $str);
$str = str_replace(':-S', '<img src="smile/wacko.png" />', $str);
return $str;
}
$ThatText2 = str_replace("<br>", "\r",$ThatText2); // Umbrüche
$ThatText=parse_bbcode($ThatText2);
$ThatText=nl2br($ThatText);