用户名:
密 码: 记住
您当前的位置:首页 > 网络编程 > php教程

php中Ubb代码编辑器程序代码

时间:2015-01-23  来源:西部数据  作者:西部数据
  1. <?php  
  2. /*  
  3. php Ubb代码编辑器  
  4. */  
  5. function get_ubb($ubb){  
  6. $ubb=preg_replace("/([B])(.*)([/B])/","<B>2</B>" ,$ubb);//替换B粗体字  
  7. $ubb=preg_replace("/([I])(.*)([/I])/","<I>2</I>" ,$ubb);  
  8. $ubb=preg_replace("/([U])(.*)([/U])/","<U>2</U>" ,$ubb);  
  9. $ubb=preg_replace("/([LEF])(.*)([/LEF])/","<div align=left>2</div>" ,$ubb);  
  10. $ubb=preg_replace("/([MID ])(.*)([/MID ])/","<div align=center>2</div>" ,$ubb);  
  11. $ubb=preg_replace("/([RIG])(.*)([/RIG])/","<div align=right>2</div>" ,$ubb);  
  12. $ubb=preg_replace("/([LINK])(.*)([/LINK])/","<a href=2>2</a>",$ubb);  
  13. $ubb=preg_replace("/([Email])(.*)([/Email])/","<a href=mailto:2>2</a>",$ubb);  
  14. $ubb=preg_replace("/([IMAGE])(.*)([/IMAGE])/","<img src=2>",$ubb);  
  15. $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);  
  16. $ubb=preg_replace("/([MUSIC])(.*)([/MUSIC])/","<embed src=2 autostart=false loop=3>" ,$ubb);  
  17. $ubb=preg_replace("/([PHOTO name=)([0-9]*)(])/","<img src=Ubb_img/biaoqing/2.gif >" ,$ubb);  
  18. $ubb=preg_replace("/([FONT=)(.{1,10})(])(.*)([/FONT])/","<div style=font:2>4</div>" ,$ubb);  
  19. $ubb=preg_replace("/([FONT-SIZE=)([0-9]*)(])(.*)([/FONT-SIZE])/","<div style=font-size:2px>4</div>" ,$ubb);  
  20. $ubb=preg_replace("/([FONT-COLOR=)(.{1,10})(])(.*)([/FONT-COLOR])/","<div style=color:2>4</div>" ,$ubb);  
  21. //$ubb=preg_replace("/([])(.*)([/])/","" ,$ubb);  
  22. return $ubb;  
  23. }  
  24. $str=get_ubb($_POST['cont']);  
  25. $str="<div style=font:宋体>[FONT=黑体]asdasd</div><div style=font:Georgia>asdasdas[/FONT]</div>";  
  26. echo get_ubb($str);  
  27. ?> 
来顶一下
返回首页
返回首页
推荐资讯
WiFi太不安全:7岁女孩11分钟内入侵公共网络 WiFi太不安全:7岁女孩11分钟内入侵近期刚刚发布研究说WiFi网络能获得人们手机里多少私人信息,
不服跑个分?人工智能也出现“刷分”乱象 不服跑个分?人工智能也出现“刷分2014年,人工智能领域突然爆发,成为了科研和科技创业的热门
相关文章
栏目更新
栏目热门