PHP UBB Code Editor program code

Source: Internet
Author: User
The code is as follows Copy Code

<?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" Quality=high 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);
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.