Copy Code code as follows:
<?php
/*
PHP UBB Code Editor
*/
function Get_ubb ($ubb) {
$ubb =preg_replace ("/([B]) (. *) ([/II])/", "<B>\2</B>", $ubb);//replace bold word in B
$ubb =preg_replace ("/([I]) (. *) ([I])/", "<I>\2</I>", $ubb);
$ubb =preg_replace ("/([u]) (. *) ([u])/", "<U>\2</U>", $ubb);
$ubb =preg_replace ("/([LEF]) (. *) ([/lef])/", "<div align=left>\2</div>", $ubb);
$ubb =preg_replace ("/([MID]) (. *) ([/mid])/", "<div align=center>\2</div>", $ubb);
$ubb =preg_replace ("/[RIG]) (. *) ([/rig])/", "<div align=right>\2</div>", $ubb);
$ubb =preg_replace ("/([LINK]) (. *) ([/link])/", "<a href=\2>\2</a>", $ubb);
$ubb =preg_replace ("/[Email]) (. *) ([/email])/", "<a href=mailto:\2>\2</a>", $ubb);
$ubb =preg_replace ("/([IMAGE]) (. *) ([/image])/", "$ubb =preg_replace ("/([FLASH]) (. *) ([/flash])/", "<object Codebase=http://download.macromedia.com/pub/shockwave /cabs/flash/swflash.cab#version=4,0,2,0 classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 width=400 height=400 ><param name=movie value= "\2" ><param name=quality "value=high><embed src=" \2 Pluginspage= ' http://www.macromedia.com/shockwave/download/index.cgi? P1_prod_version=shockwaveflash ' type= ' Application/x-shockwave-flash ' width=400 height=400 ></embed></ Object> ", $ubb);
$ubb =preg_replace ("/[MUSIC]) (. *) ([/music])/", "<embed src=\2 autostart=false loop=3>", $ubb);
$ubb =preg_replace ("/([PHOTO name=) ([0-9]*) (])/", "$ubb =preg_replace ("/() (. { 1,10}) (]) (. *) ([/font])/"," <div style=font:\2>\4</div> ", $ubb);
$ubb =preg_replace ("/([font-size=) ([0-9]*) (]) (. *) ([/font-size])/", "<div style=font-size:\2px>\4</div > ", $ubb);
$ubb =preg_replace ("/" [font-color=) (. { 1,10}) (]) (. *) ([/font-color])/"," <div style=color:\2>\4</div> ", $ubb);
$ubb =preg_replace ("/[]) (. *) ([/])/", "", $ubb);
return $ubb;
}
$str =get_ubb ($_post[' cont '));
$str = "<div style=font: XXFarEastFont->[font= Bold]asdasd</div><div Style=font:georgia>asdasdas[/font]</div > ";
echo Get_ubb ($STR);
?>