<?php
error_reporting(E_ALL);
function BBCode($Text)
{
$Text = str_replace("<", "<", $Text);
$Text = str_replace(">", ">", $Text);
$URLSearchString = " a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'";
$MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@";
if (substr($Text,0, 7) == "http://"){
$Text = eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", "<a href=\"\\1://\\2\\3\">\\1://\\2\\3</a>", $Text);
$Text = nl2br($Text);
} else {
$Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="javascript:go(\'$1\',\'new\')">$1</a>', $Text);
$Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '<a href="javascript:go(\'$1\',\'new\')">$2</a>', $Text);
$Text = nl2br($Text);
}
$Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href="mailto:$1">$1</a>', $Text);
$Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '<a href="mailto:$1">$2</a>', $Text);
$Text = preg_replace("(\[b\](.+?)\[\/b])is",'<span class="bold">$1</span>',$Text);
$Text = preg_replace("(\[i\](.+?)\[\/i\])is",'<span class="italics">$1</span>',$Text);
$Text = preg_replace("(\[u\](.+?)\[\/u\])is",'<span class="underline">$1</span>',$Text);
$Text = preg_replace("(\[s\](.+?)\[\/s\])is",'<span class="strikethrough">$1</span>',$Text);
$Text = preg_replace("(\[o\](.+?)\[\/o\])is",'<span class="overline">$1</span>',$Text);
$Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","<span style=\"color: $1\">$2</span>",$Text);
$Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","<span style=\"font-size: $1px\">$2</span>",$Text);
$Text = preg_replace("/\
[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>' ,$Text);
$Text = preg_replace("/\
[list=1\](.+?)\[\/list\]/is", '<ul class="listdecimal">$1</ul>' ,$Text);
$Text = preg_replace("/\
[list=i\](.+?)\[\/list\]/s", '<ul class="listlowerroman">$1</ul>' ,$Text);
$Text = preg_replace("/\
[list=I\](.+?)\[\/list\]/s", '<ul class="listupperroman">$1</ul>' ,$Text);
$Text = preg_replace("/\
[list=a\](.+?)\[\/list\]/s", '<ul class="listloweralpha">$1</ul>' ,$Text);
$Text = preg_replace("/\
[list=A\](.+?)\[\/list\]/s", '<ul class="listupperalpha">$1</ul>' ,$Text);
$Text = str_replace("
[*]", "<li>", $Text);
$Text = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])","<span style=\"font-family: $1;\">$2</span>",$Text);
$Text = str_replace(':P', '<img src="../layout/smileys/000.gif" width="15" height="14" border="0">', $Text);
$Text = str_replace(':)', '<img src="../layout/smileys/001.gif" width="15" height="14" border="0">', $Text);
$Text = str_replace(';)', '<img src="../layout/smileys/002.gif" width="15" height="14" border="0">', $Text);
$Text = str_replace(':(', '<img src="../layout/smileys/003.gif" width="15" height="14" border="0">', $Text);
$Text = str_replace('*grr*', '<img src="../layout/smileys/004.gif" width="15" height="14" border="0">', $Text);
$Text = str_replace('0.o', '<img src="../layout/smileys/005.gif" width="15" height="14" border="0">', $Text);
$Text = str_replace('*_*', '<img src="../layout/smileys/006.gif" width="15" height="14" border="0">', $Text);
$Text = str_replace('._.', '<img src="../layout/smileys/007.gif" width="15" height="14" border="0">', $Text);
$Text = str_replace('-.-', '<img src="../layout/smileys/008.gif" width="15" height="14" border="0">', $Text);
$Text = str_replace(':D', '<img src="../layout/smileys/009.gif" width="15" height="14" border="0">', $Text);
return $Text;
}
?>