while($box = mysql_fetch_array($result))
{
$max = 10; //maximale Länge, die die URL haben darf
preg_match_all ('=\[ url\](<a href="http://.+\." target="_blank">[ url]http://.+\.[ /url]</a>[a-z]+)\[ /url\]=isU', $box['message'], $matchtes);
foreach ($matches as $key => $value) {
$url = (strlen($matches[1][$key]) > $max) ? substr($matches[1][$key], 0 , $max-1)."..." : $matches[1][$key];
$box['message']=str_replace ($matches[0][$key], '<a href="'.$matches[1][$key].'" target="_blank">'.$url.'</a>', $box['message']);}
$box['message']=str_replace (':)', '<img src="http://yourip.de/images/smilies/icon_smile.gif">', $box['message']);
$box['message']=str_replace (';)', '<img src="http://yourip.de/images/smilies/icon_wink.gif">', $box['message']);
$box['message']=str_replace (':D', '<img src="http://yourip.de/images/smilies/icon_biggrin.gif">', $box['message']);
$box['message']=str_replace (':-D', '<img src="http://yourip.de/images/smilies/icon_cheesygrin.gif">', $box['message']);
$box['message']=str_replace (':O', '<img src="http://yourip.de/images/smilies/icon_surprised.gif">', $box['message']);
$box['message']=str_replace (':P', '<img src="http://yourip.de/images/smilies/icon_razz.gif">', $box['message']);
$box['message']=str_replace ('(lol)', '<img src="http://yourip.de/images/smilies/icon_lol.gif">', $box['message']);
$box['message']=str_replace ('(cool)', '<img src="http://yourip.de/images/smilies/icon_cool.gif">', $box['message']);
$box['message']=str_replace ('(green)', '<img src="http://yourip.de/images/smilies/icon_mrgreen.gif">', $box['message']);
$box['message']=str_replace (':S', '<img src="http://yourip.de/images/smilies/icon_confused.gif">', $box['message']);
$box['message']=str_replace ('*-)', '<img src="http://yourip.de/images/smilies/icon_rolleyes.gif">', $box['message']);
$box['message']=str_replace ('8-|', '<img src="http://yourip.de/images/smilies/icon_eek.gif">', $box['message']);
$box['message']=str_replace (':|', '<img src="http://yourip.de/images/smilies/icon_neutral.gif">', $box['message']);
$box['message']=str_replace (':*(', '<img src="http://yourip.de/images/smilies/icon_cry.gif">', $box['message']);
$box['message']=str_replace (':(', '<img src="http://yourip.de/images/smilies/icon_sad.gif">', $box['message']);
$box['message']=str_replace ('(frown)', '<img src="http://yourip.de/images/smilies/icon_frown.gif">', $box['message']);
$box['message']=str_replace (':@', '<img src="http://yourip.de/images/smilies/icon_mad.gif">', $box['message']);
$box['message']=str_replace ('(red)', '<img src="http://yourip.de/images/smilies/icon_redface.gif">', $box['message']);
$box['message']=str_replace ('(6)', '<img src="http://yourip.de/images/smilies/icon_twisted.gif">', $box['message']);
$box['message']=str_replace ('(idee)', '<img src="http://yourip.de/images/smilies/icon_idea.gif">', $box['message']);
$box['message']=str_replace ('(right)', '<img src="http://yourip.de/images/smilies/icon_arrow.gif">', $box['message']);
$box['message']=str_replace ('(left)', '<img src="http://yourip.de/images/smilies/icon_arrowl.gif">', $box['message']);
$box['message']=str_replace ('(down)', '<img src="http://yourip.de/images/smilies/icon_arrowd.gif">', $box['message']);
$box['message']=str_replace ('(up)', '<img src="http://yourip.de/images/smilies/icon_arrowu.gif">', $box['message']);
$box['message']=str_replace ('(!)', '<img src="http://yourip.de/images/smilies/icon_exclaim.gif">', $box['message']);
$box['message']=str_replace ('(?)', '<img src="http://yourip.de/images/smilies/icon_question.gif">', $box['message']);
$box['message']=str_replace ('[br]', '<br>', $box['message']);
$box['message']=eregi_replace ('\[b\]', '<b>', $box['message']);
$box['message']=eregi_replace ('\[\/b\]', '</b>', $box['message']);
$box['message']=eregi_replace ('\[u\]', '<u>', $box['message']);
$box['message']=eregi_replace ('\[\/u\]', '</u>', $box['message']);
$box['message']=eregi_replace ('\[i\]', '<i>', $box['message']);
$box['message']=eregi_replace ('\[\/i\]', '</i>', $box['message']);
$box['message']=preg_replace ("=(\[\/c\]|\[\/code\]|^) (.*)(http:\/\/|http:\/\/www\.|https:\/\/|https:\/\/www\.|ftp:\/\/)([a-zA-Z0-9\.\/\-\_]{1,})(.*)(\[c\]|\[code\]|$)=i", "\\1\\2<a href=\"\\3\\4\" target=\"_blank\">\\3\\4</a>\\5\\6", $box['message']); // Links wurden mit Protokoll angegeben
$box['message']=preg_replace ("=(\[\/c\]|\[\/code\]|^)(.*)(www\.)([a-zA-Z0-9\.\/\-\_]{1,})(.*)(\[c\]|\[code\]|$)=i", "\\1\\2<a href=\"http:\/\/\\3\\4\" target=\"_blank\">\\3\\4</a>\\5\\6", $box['message']); // Links ohne Protokoll, aber mit www beginnend
$box['message']=preg_replace ("=(\[\/c\]|\[\/code\]|^)(.*)\[url\]([\ ]*)(http:\/\/|http:\/\/www\.|https:\/\/|https:\/\/www\.|ftp:\/\/)([a-zA-Z0-9\.\/\-\_]{1,})([\ ]*)\[/url\](.*)(\[c\]|\[code\]|$)=i", "\\1\\2\\3<a href=\"\\4\\5\" target=\"_blank\">\\4\\5</a>\\6\\7", $box['message']); // BB-codierte Links (von und eingeschlossen)
$box['message']=preg_replace ("=(\[\/c\]|\[\/code\]|^)(.*)\[url\]([\ ]*)(www\.)([a-zA-Z0-9\.\/\-\_]{1,})([\ ]*)\[/url\](.*)(\[c\]|\[code\]|$)=i", "\\1\\2\\3<a href=\"http:\/\/\\4\\5\" target=\"_blank\">\\4\\5</a>\\6\\7", $box['message']); // BB-codierte Links ohne Protokoll, aber mit www beginnend
$box['message']=preg_replace ("=(\[\/c\]|\[\/code\]|^)(.*)\[url\=[\"\']?(http:\/\/|http:\/\/www\.|https:\/\/|https:\/\/www\.|ftp:\/\/)([a-zA-Z0-9\.\/\-\_]{1,})[\"\']?\](.*?)\[\/url\](.*)(\[c\]|\[code\]|$)=i", "\\1\\2<a href=\"\\3\\4\">\\5</a>\\6\\7", $box['message']); // BB-codierte Links mit Beschreibung
$box['message']=preg_replace ("=(\[\/c\]|\[\/code\]|^)(.*)\[url\=[\"\']?(www\.)([a-zA-Z0-9\.\/\-\_]{1,})[\"\']?\](.*)\[/url\](.*)(\[c\]|\[code\]|$)=i", "\\1\\2<a href=\"http:\/\/\\3\\4\">\\5</a>\\6\\7", $box['message']); // BB-codierte mit www beginnende Links ohne Protokoll aber mit Linkbeschreibung
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)([a-zA-Z0-9\.\/\-\_]{1,})@([a-zA-Z0-9\.\/\-\_]{1,})(.*)(\[code\]|\[c\]|$)=i","\\1\\2<a href=\"mailto:\\3@\\4\">\\3@\\4</a>\\5\\6",$box['message']); // normale eMail-Adresse
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)\[email\]([a-zA-Z0-9\.\/\-\_]{1,})@([a-zA-Z0-9\.\/\-\_]{1,})\[\/email\](.*)(\[code\]|\[c\]|$)=i","\\1\\2<a href=\"mailto:\\3@\\4\">\\3@\\4</a>\\5\\6",$box['message']); // BB-codierte eMail-Adresse (von [ EMAIL] und [ /EMAIL] eingeschlossen)
$box['message']=preg_replace ("=(\[\/code]|\[\/c]|^)(.*)\[email\=[\"\']?([a-zA-Z0-9\.\/\-\_]{1,})@([a-zA-Z0-9\.\/\-\_]{1,})[\"\']?\](.*?)\[\/email\](.*)(\[code\]|\[c\]|$)=i","\\1\\2<a href=\"mailto:\\3@\\4\">\\5</a>\\6\\7",$box['message']); // BB-codierte eMail-Adressen mit Beschreibung
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)(?:\[q\]|\[quote\])(.*?)(?:\[\/q\]|\[\/quote\])(.*)(\[code\]|\[c\]|$)=i", "\\1\\2<blockquote>\\3</blockquote>\\4\\5", $box['message']);
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)\[i\](.*?)\[\/i\](.*)(\[code\]|\[c\]|$)=i", "\\1\\2<i>\\3</i>\\4\\5", $box['message']); // Kursiv-Schrift
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)\[u\](.*?)\[\/u\](.*)(\[code\]|\[c\]|$)=i", "\\1\\2<u>\\3</u>\\4\\5", $box['message']); // Unterstreichung
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)\[b\](.*?)\[\/b\](.*)(\[code\]|\[c\]|$)=i", "\\1\\2<b>\\3</b>\\4\\5", $box['message']); // Fettschrift
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)\[p\](.*?)\[\/p\](.*)(\[code\]|\[c\]|$)=i", "\\1\\2<p>\\3</p>\\4\\5", $box['message']); // Absatz
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)\[center\](.*?)\[\/center\](.*)(\[code\]|\[c\]|$)=i", "\\1\\2<center>\\3</center>\\4\\5", $box['message']); // Zentrierung
$box['message']=str_replace ("[br]","<br>",$box['message']);
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)\[verdana\](.*?)\[\/verdana\](.*)(\[code\]|\[c\]|$)=i", "\\1\\2<span style=\"font-family:verdana;\">\\3</span>\\4\\5", $box['message']); // Schrifttyp: Verdana
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)\[verdana\](.*?)\[\/verdana\](.*)(\[code\]|\[c\]|$)=i", "\\1\\2<span style=\"font-family:times;\">\\3</span>\\4\\5", $box['message']); // Schrifttyp: Times
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)\[verdana\](.*?)\[\/verdana\](.*)(\[code\]|\[c\]|$)=i", "\\1\\2<span style=\"font-family:verdana;\">\\3</span>\\4\\5", $box['message']); // Schrifttyp: Arial
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)(?:\[q\]|\[quote\])(.*?)(?:\[\/q\]|\[\/quote\])(.*)(\[code\]|\[c\]|$)=i", "\\1\\2<blockquote>\\3</blockquote>\\4\\5", $box['message']); // Zitat
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)\[list\](.*?)\[\/list\](.*)(\[code\]|\[c\]|$)=i", "\\1\\2<ul>\\3</ul>\\4\\5", $box['message']); // unnummerierte Liste
$box['message']=preg_replace ("=(\[\/code\]|\[\/c\]|^)(.*)\[numlist\](.*?)\[\/numlist\](.*)(\[code\]|\[c\]|$)=i", "\\1\\2<ol>\\3</ol>\\4\\5", $box['message']); // nummerierte Liste
$box['message']=eregi_replace ("\[-\]", "<li>", $box['message']); // Listenelement
$box['message']=preg_replace ("=(?:\[c\]|\[code\])(.*?)(?:\[\/c\]|\[\/code\])=i", "<span class=\"code\"><code>\\1</code></span>", $box['message']); // Quellcode
$box['message']=eregi_replace ('\[glow\]','<span style="filter:glow(color=#C7DDF3); height:1">', $box['message']);
$box['message']=eregi_replace ('\[\/glow\]','</span>', $box['message']);
$box['message']=eregi_replace ('\[mark\]','<span style="background:#C7DDF3;color:black">', $box['message']);
$box['message']=eregi_replace ('\[\/mark\]','</span>', $box['message']);
$box['message']=nl2br ($box['message']);
if(preg_match("=(\[\/code\]|\[\/c\]|^)(.*)(\[img\])([a-zA-Z0-9\.\/\-\_\:]{1,})(\[/img\])(.*)(\[code\]|\[c\]|$)=i",$box['message'],$url)) {
$info=getimagesize($url[3]);
if(($info[2]>3)||($info[2]<1)) {
$replace="<a href=\"".$url[3]."\" target=\"_blank\">** Eingefügtes Bild **</a>";
}
else {
if($info[0]<=$pic_maxx) $replace="<center><img src=\"".$url[3]."\" width=\"".$info[0]."\" height=\"".$info[1]."\"></center>";
else {
$faktor=$pic_maxx/$info[0];
$info[0]=$info[0]*$faktor;
$info[1]=$info[1]*$faktor;
$replace="<center><img src=\"".$url[3]."\" width=\"".$info[0]."\" height=\"".$info[1]."\"></center>";
}
}
$box['message']=preg_replace("=(\[\/code\]|\[\/c\]|^)(.*)\[img\]([a-zA-Z0-9\.\/\-\_\:]{1,})\[/img\](.*)(\[code\]|\[c\]|$)=i",$replace,$box['message']);
}