bb code function:
PHP Code:
function bbcode($text)
{
// global $smilies;
$text=htmlspecialchars($text);
$text=preg_replace("/\[b\]\[big\](.*?)\[\/b\]\[\/big\]/i","[b]<big>\\1</big>[/b]", $text);
$text=preg_replace("/\[big\]\[b\](.*?)\[\/big\]\[\/b\]/i","[b]<big>\\1</big>[/b]", $text);
$text=preg_replace("/\[u\]\[big\](.*?)\[\/u\]\[\/big\]/i","[u]<big>\\1</big>[/u]", $text);
$text=preg_replace("/\[big\]\[u\](.*?)\[\/big\]\[\/u\]/i","[u]<big>\\1</big>[/u]", $text);
$text=preg_replace("/\[b\]\[u\](.*?)\[\/b\]\[\/u\]/i","[b][u]\\1[/u][/b]", $text);
$text=preg_replace("/\[u\]\[b\](.*?)\[\/u\]\[\/b\]/i","[b][u]\\1[/u][/b]", $text);
$text=preg_replace("/\[b\]\[i\](.*?)\[\/b\]\[\/i\]/i","[b][i]\\1[/i][/b]", $text);
$text=preg_replace("/\[i\]\[b\](.*?)\[\/i\]\[\/b\]/i","[b][i]\\1[/i][/b]", $text);
$text=preg_replace("/\[b\]\[u\](.*?)\[\/b\]\[\/u\]/i","[b][u]\\1[/u][/b]", $text);
$text=preg_replace("/\[u\]\[b\](.*?)\[\/u\]\[\/b\]/i","[b][u]\\1[/u][/b]", $text);
$text=preg_replace("/\[b\]\[small\](.*?)\[\/b\]\[\/small\]/i","[size="1"][b]\\1[/b][/size]", $text);
$text=preg_replace("/\[small\]\[b\](.*?)\[\/small\]\[\/b\]/i","[size="1"][b]\\1[/b][/size]", $text);
$text=preg_replace("/\[i\]\[small\](.*?)\[\/i\]\[\/small\]/i","[size="1"][i]\\1[/i][/size]", $text);
$text=preg_replace("/\[small\]\[i\](.*?)\[\/small\]\[\/i\]/i","[size="1"][i]\\1[/i][/size]", $text);
$text=preg_replace("/\[u\]\[small\](.*?)\[\/u\]\[\/small\]/i","[size="1"][u]\\1[/u][/size]", $text);
$text=preg_replace("/\[small\]\[u\](.*?)\[\/small\]\[\/u\]/i","[size="1"][u]\\1[/u][/size]", $text);
$text=preg_replace("/\[b\]\[big\](.*?)\[\/b\]\[\/big\]/i","<big>[b]\\1[/b]</big>", $text);
$text=preg_replace("/\[big\]\[b\](.*?)\[\/big\]\[\/b\]/i","<big>[b]\\1[/b]</big>", $text);
$text=preg_replace("/\[i\]\[big\](.*?)\[\/i\]\[\/big\]/i","<big>[i]\\1[/i]</big>", $text);
$text=preg_replace("/\[big\]\[i\](.*?)\[\/big\]\[\/i\]/i","<big>[i]\\1[/i]</big>", $text);
$text=preg_replace("/\[u\]\[big\](.*?)\[\/u\]\[\/big\]/i","<big>[u]\\1[/u]</big>", $text);
$text=preg_replace("/\[big\]\[u\](.*?)\[\/big\]\[\/u\]/i","<big>[u]\\1[/u]</big>", $text);
$text=preg_replace("/\[b\](.*?)\[\/b\]/i","[b]\\1[/b]", $text);
$text=preg_replace("/\[u\](.*?)\[\/u\]/i","[u]\\1[/u]", $text);
$text=preg_replace("/\[i\](.*?)\[\/i\]/i","[i]\\1[/i]", $text);
$text=preg_replace("/\[big\](.*?)\[\/big\]/i","<big>\\1</big>", $text);
$text=preg_replace("/\[small\](.*?)\[\/small\]/i","[size="1"]\\1[/size]", $text);
$text=preg_replace("/\[br\/\]/i","
", $text);
$text=preg_replace("/\[url\](.*?)\[\/url\]/i","<a href=\"\\1\">\\1</a>", $text);
$text=preg_replace("/\[link\=(.*?)\](.*?)\[\/link\]/i","<a href=\"\\1\">\\2</a>", $text);
$text=preg_replace("/\[img\=((.*?)(.jpg|jpeg))\]/i","<a href=\"\\1\"><img src=\"\\1\" alt=\"***\"/></a>", $text);
$text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})','[email="\\1"]\\1[/email]', $text);
}
Comment