<?
function bbcode($text){
$text=preg_replace("/\[i\](.+?)\[\/i\]/s", '<i>$1</i>',$text);
$text=preg_replace("/\[b\](.+?)\[\/b\]/s", '<b>$1</b>',$text);
$text=preg_replace("/\[u\](.+?)\[\/u\]/s", '<u>$1</u>',$text);
$text=preg_replace("/\[quote\](.+?)\[\/quote\]/s", '<table width="95%" align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code_t">Quote:</td></tr><tr><td class="code" width="100%">$1</td></tr></tbody></table>',$text);
$text=preg_replace("/\[quote\=(.+?)](.+?)\[\/quote\]/s", '<table width="95%" align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code_t">$1 say:</td></tr><tr><td class="code" width="100%">$2</td></tr></tbody></table>',$text);
$text=preg_replace("/\[url\](.+?)\[\/url\]/s", '<a href="$1">$1</a>',$text);
$text=preg_replace("/\[url\=(.+?)\](.+?)\[\/url\]/s", '<a href="$1">$2</a>',$text);
$text=preg_replace("/\[img\](.+?)\[\/img\]/s", '<a href="$1" target="_blank"><img src="$1" width="250" height="250" alt="Кликни на снимката за Пълен размер" title="User submitted image"/></a>',$text);
$text=preg_replace("/\[color\=(.+?)\](.+?)\[\/color\]/s", '<span style="color:$1">$2</span>',$text);
$text=preg_replace("/\[size\=(.+?)\](.+?)\[\/size\]/s", '<span style="font-size:$1">$2</span>',$text);
$text=preg_replace("/\[code\](.+?)\[\/code\]/s",'<table width="95%" align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code_t">Code:</td></tr><tr><td class="code" width="100%">$1</td></tr></tbody></table>',$text);
$text = nl2br($text);
return $text;
}
?>