<?

function bbcode($text)
{

// no html codes
$text=htmlspecialchars($text);

// <br>
$text=nl2br($text);

// <b>
$text=str_replace("[B]","<b>",$text);
$text=str_replace("[/B]","</b>",$text);

// <u>
$text=str_replace("[U]","<u>",$text);
$text=str_replace("[/U]","</u>",$text);

// <i>
$text=str_replace("[I]","<i>",$text);
$text=str_replace("[/I]","</i>",$text);

// <a>
$text=str_replace("[url=","<a target=_blank href=",$text);
$text=str_replace("[/url","</a",$text);
$text=str_replace("[mail=","<a href=mailto:",$text);
$text=str_replace("[/mail","</a",$text);

// images,Flash,Media And Ram - Rm - Files
$text=str_replace("[img]","<img src=",$text);
$text=str_replace("[/img]",">",$text);
$text=str_replace("[bimg=","<img border=0 width=100 height=100 src=",$text);
$text=str_replace("[/bimg","",$text);
$text=str_replace("[flash=","<EMBED quality=high loop=true menu=false  TYPE=application/x-shockwave-flash src= ",$text);
$text=str_replace("[/flash","</embed",$text);
$text=str_replace("[media=","<div align=center><embed src=",$text);
$text=str_replace("[/media","</div></embed",$text);
$text=str_replace("[rams=","<div align=center><embed type=audio/x-pn-realaudio-plugin CONSOLE=Clip1
CONTROLS=ControlPanel,StatusBar HEIGHT=60 WIDTH=300
AUTOSTART=false SRC=",$text);
$text=str_replace("[/rams","</embed></div",$text);
$text=str_replace("[ramv=","<div align=center><embed type=audio/x-pn-realaudio-plugin CONSOLE=Clip1
CONTROLS=ImageWindow,ControlPanel,StatusBar HEIGHT=230 WIDTH=300
AUTOSTART=false SRC=",$text);
$text=str_replace("[/ramv","</embed></div",$text);

// Extra Codes : Line , Quote , Code and PHP
$text=str_replace("[line","<hr",$text);
$text=str_replace("[quote","<center><table cellspacing=0 cellpadding=6 border=1 width=60%><tr><td align=right dir=rtl",$text);
$text=str_replace("[/quote","</td></tr></table></center",$text);
$text=str_replace("[code","<table  cellspacing=0 cellpadding=0 border=1 width=60%><tr><td align=left bgcolor=#D6D3D6><font color=orange>Code :</font><br",$text);
$text=str_replace("[/code","</td></tr></table",$text);
$text=str_replace("[php","<center><table cellspacing=0 cellpadding=6 border=1 width=90%><tr><td align=left dir=ltr bgcolor=#f5f5f5><font color=orange>PHP :</font>
<font face=tahoma size=2><br",$text);
$text=str_replace("[/php","</td></tr></table",$text);

// Fonts And Div
$text=str_replace("[color=","<font color=",$text);
$text=str_replace("[/color","</font",$text);
$text=str_replace("[font=","<font face=",$text);
$text=str_replace("[/font","</font",$text);
$text=str_replace("[size=","<font size=",$text);
$text=str_replace("[/size","</font",$text);
$text=str_replace('[align=','<div align=', $text);
$text=str_replace('[/align]','</div>', $text);
$text=str_replace(']','>',$text);
$text=stripslashes($text);

// MOVE
$text=str_replace("[move=","<marquee scrolldelay=120 direction=",$text);
$text=str_replace("[/move","</marquee",$text);



//Smiles
$text=str_replace(":)","<img src=images/Default/smiles/1.gif>",$text);
$text=str_replace(":(","<img src=images/Default/smiles/2.gif>",$text);
$text=str_replace(":confused","<img src=images/Default/smiles/confused.gif>",$text);
$text=str_replace(":cool","<img src=images/Default/smiles/cool.gif>",$text);
$text=str_replace(":eek","<img src=images/Default/smiles/eek.gif>",$text);
$text=str_replace(":biggrin","<img src=images/Default/smiles/biggrin.gif>",$text);
$text=str_replace(":wink","<img src=images/Default/smiles/wink.gif>",$text);
$text=str_replace(":mad","<img src=images/Default/smiles/mad.gif>",$text);
$text=str_replace(":redface","<img src=images/Default/smiles/redface.gif>",$text);
$text=str_replace(":good","<img src=images/Default/smiles/good.gif>",$text);
$text=str_replace(":bad","<img src=images/Default/smiles/bad.gif>",$text);


return $text;
}


function BBcode2comm($text){
$text=str_replace("[php]","<center><table cellspacing=0 cellpadding=6 border=1 width=90%><tr><td align=left dir=ltr bgcolor=#f5f5f5><font color=orange>PHP :<br></font>
<font face=tahoma size=2><br",$text);
//Smiles
$text=str_replace(":)","<img src=images/Default/smiles/1.gif>",$text);
$text=str_replace(":(","<img src=images/Default/smiles/2.gif>",$text);
$text=str_replace(":confused","<img src=images/Default/smiles/confused.gif>",$text);
$text=str_replace(":cool","<img src=images/Default/smiles/cool.gif>",$text);
$text=str_replace(":eek","<img src=images/Default/smiles/eek.gif>",$text);
$text=str_replace(":biggrin","<img src=images/Default/smiles/biggrin.gif>",$text);
$text=str_replace(":wink","<img src=images/Default/smiles/wink.gif>",$text);
$text=str_replace(":mad","<img src=images/Default/smiles/mad.gif>",$text);
$text=str_replace(":redface","<img src=images/Default/smiles/redface.gif>",$text);
$text=str_replace(":good","<img src=images/Default/smiles/good.gif>",$text);
$text=str_replace(":bad","<img src=images/Default/smiles/bad.gif>",$text);


return $text;
}





function delbbcode($text)
{

// no html codes
$text=htmlspecialchars($text);

// <br>
$text=nl2br($text);

// <b>
$text=str_replace("[B]","",$text);
$text=str_replace("[/B]","",$text);

// <u>
$text=str_replace("[U]","",$text);
$text=str_replace("[/U]","",$text);

// <i>
$text=str_replace("[I]","",$text);
$text=str_replace("[/I]","",$text);

// <a>
$text=str_replace("[url=","",$text);
$text=str_replace("[/url","",$text);
$text=str_replace("[mail=","",$text);
$text=str_replace("[/mail","",$text);

// images,Flash,Media And Ram - Rm - Files
$text=str_replace("[img]","",$text);
$text=str_replace("[/img]","",$text);
$text=str_replace("[bimg=","",$text);
$text=str_replace("[/bimg","",$text);
$text=str_replace("[flash=","",$text);
$text=str_replace("[/flash","",$text);
$text=str_replace("[media=","",$text);
$text=str_replace("[/media","",$text);
$text=str_replace("[rams=","",$text);
$text=str_replace("[/rams","",$text);
$text=str_replace("[ramv=","",$text);
$text=str_replace("[/ramv","",$text);

// Extra Codes : Line , Quote , Code and PHP
$text=str_replace("[line","",$text);
$text=str_replace("[quote","",$text);
$text=str_replace("[/quote","",$text);
$text=str_replace("[code","",$text);
$text=str_replace("[/code","",$text);
$text=str_replace("[php","",$text);
$text=str_replace("[/php","",$text);

// Fonts And Div
$text=str_replace("[color=","",$text);
$text=str_replace("[/color","",$text);
$text=str_replace("[font=","",$text);
$text=str_replace("[/font","",$text);
$text=str_replace("[size=","",$text);
$text=str_replace("[/size","",$text);
$text=str_replace('[align=','', $text);
$text=str_replace('[/align]','', $text);
$text=str_replace(']','',$text);
$text=stripslashes($text);

// MOVE
$text=str_replace("[move=","",$text);
$text=str_replace("[/move","",$text);



//Smiles
$text=str_replace(":)","",$text);
$text=str_replace(":(","",$text);
$text=str_replace(":confused","",$text);
$text=str_replace(":cool","",$text);
$text=str_replace(":eek","",$text);
$text=str_replace(":biggrin","",$text);
$text=str_replace(":wink","",$text);
$text=str_replace(":mad","",$text);
$text=str_replace(":redface","",$text);
$text=str_replace(":good","",$text);
$text=str_replace(":bad","",$text);


return $text;
}




?>