php专区

 首页 > php专区 > PHP应用 > 常用功能 > php的把ubb代码转换成html代码的程序 - php高级应用

php的把ubb代码转换成html代码的程序 - php高级应用

分享到:
【字体:
导读:
          ?phpfunctionubbcode($str){ $str=str_replace(file:,file:,$str); $str=str_replace(files:,files:,$str); $str=str_replace(...

php的把ubb代码转换成html代码的程序

  1. function ubbcode($str){ 
  2.  //$str = str_replace("file:","file :",$str); 
  3.  //$str = str_replace("files:","files :",$str); 
  4.  //$str = str_replace("script:","script :",$str); 
  5.  //$str = str_replace("js:","js :",$str); 
  6.      
  7.  //图片UBB 
  8.  $str = preg_replace("/[img](http|https|ftp)://(.[^[]*)[/img]/i"""$str); 
  9.  $str = preg_replace("/[img=*([0-9]*),*([0-9]*)](http|https|ftp)://(.[^[]*)[/img]/i"""$str); 
  10.   
  11.  $str = preg_replace("/([img])images/face/em(.*?).gif([/img])/i"""$str);  
  12.  //链接UBB 
  13.  $str = preg_replace("/([url])(.[^[]*)([url])/i""${1}"$str); 
  14.  $str = preg_replace("/[url=(.[^[]*)]/i"""$str); 
  15.  //邮箱UBB 
  16.  $str = preg_replace("/([email])(.*?)([/email])/i""${2}"$str); 
  17.  $str = preg_replace("/[email=(.[^[]*)]/i"""$str); 
  18.  //QQ号码UBB 
  19.  $str = preg_replace("/[qq=([0-9]*)]([0-9]*)[/qq]/i"""$str); 
  20.  //颜色UBB 
  21.  $str = preg_replace("/[color=(.[^[]*)]/i"""$str); 
  22.  //文字字体UBB 
  23.  $str = preg_replace("/[font=(.[^[]*)]/i"""$str); 
  24.  //文字大小UBB 
  25.  $str = preg_replace("/[size=([0-9]*)]/i"""$str); 
  26.  $str = preg_replace("/[size=([0-9]*)pt]/i"""$str); 
  27.  $str = preg_replace("/[size=([0-9]*)px]/i"""$str); 
  28.  //文字对齐方式UBB 
  29.  $str = preg_replace("/[align=(center|left|right)]/i"""$str); 
  30.  //表格UBB 
  31.  //$str = preg_replace("/[table=(.[^[]*)]/i", "", $str); 
  32.  //表格UBB2 
  33.  //$str = preg_replace("/[td=([0-9]*),([0-9]*),([0-9]*)]/i", "", $str); 
  34.  //字体倾斜 
  35.  $str = preg_replace("/[i]((.|n)*?)[/i]/i""${1}"$str); 
  36.  //FLASH动画UBB 
  37.  $str = preg_replace("/([flash])(http://.[^[]*(.swf))([/flash])/i""[全屏欣赏]
    ${2}
    "
    $str); 
  38.  $str = preg_replace("/([flash=*([0-9]*),*([0-9]*)])(http://.[^[]*(.swf))([/flash])/i""[全屏欣赏]
    ${4}
    "
    $str); 
  39.      
  40.  //MEDIA PLAY播放UBB 
  41.  $str = preg_replace("/[wmv](.[^[]*)[/wmv]/i"""$str); 
  42.  $str = preg_replace("/[wmv=*([0-9]*),*([0-9]*)](.[^[]*)[/wmv]/i"""$str); 
  43.      
  44.  //REALPLAY 播放UBB 
  45.  $str = preg_replace("/[rm](.[^[]*)[/rm]/i""
    "
    $str); 
  46.  $str = preg_replace("/[rm=*([0-9]*),*([0-9]*)](.[^[]*)[/rm]/i""
    "
    $str); 
  47.     $str = str_replace("rn""
    "
    $str); 
  48.  $str = preg_replace("/[rm=*([0-9]*),*([0-9]*)](.[^[]*)[/rm]/i""
    "
    $str); 
  49. /* 
  50.  re.pattern="[code]((.|n)*?)[/code]" 
  51.  Set tempcodes=re.Execute($str) 
  52.  For i=0 To tempcodes.count-1 
  53.    re.pattern="
    "
     
  54.    tempcode=Replace(tempcodes(i),"
    ",vbcrlf)
     
  55.    $str=replace($str,tempcodes(i),tempcode) 
  56.  next 
  57. */ 
  58.     $searcharray = array("[/url]","[/email]","[/color]""[/size]""[/font]""[/align]""[b]""[/b]","[u]""[/u]""[list]""[list=1]""[list=a]","[list=A]""[*]""[/list]""[indent]""[/indent]","[ DISCUZ_CODE_0 ]","[quote]","[/quote]","[tr]","[td]","[/td]","[/tr]","[/table]"); 
  59.  $replacearrayarray("","","""""""
""""","""""
    """"","""
  • ""
"
"
""
"
,"
","
     提示:您可以先修改部分代码再运行
"
,"","
","","","","",""); 
  •  for ($i=0; $i<count($searcharray); $i++){ 
  •   $str = str_replace($searcharray[$i], $replacearray[$i], $str); 
  •  } 
  •  return $str
  • /* 
  •  're.Pattern="[UPLOAD=(gif|jpg|jpeg|bmp)](.[^[]*)(gif|jpg|jpeg|bmp)[/UPLOAD]" 
  •  '$str= re.Replace($str,"
    此主题相关链接如下:
    screen.width-333)this.width=screen.width-333">")
     
  •  're.Pattern="[UPLOAD=(doc|xls|ppt|htm|swf|rar|zip|exe)](.[^[]*)(doc|xls|ppt|htm|swf|rar|zip|exe)[/UPLOAD]" 
  •  '$str= re.Replace($str,"
    此主题相关链接如下:
    点击浏览该文件")
     
  •  '自动识别网址 
  •  're.Pattern = "^((http|https|ftp|rtsp|mms):(//|\\)[A-Za-z0-9./=?%-&_~`@[]':+!]+)" 
  •  '$str = re.Replace($str,"$1") 
  •  're.Pattern = "((http|https|ftp|rtsp|mms):(//|\\)[A-Za-z0-9./=?%-&_~`@[]':+!]+)$" 
  •  '$str = re.Replace($str,"$1") 
  •  're.Pattern = "([^>="])((http|https|ftp|rtsp|mms):(//|\\)[A-Za-z0-9./=?%-&_~`@[]':+!]+)" 
  •  '$str = re.Replace($str,"$1$2") 
  •  '自动识别www等开头的网址 
  •  're.Pattern = "([^(http://|http:\)])((www|cn)[.](w)+[.]{1,}(net|com|cn|org|cc)(((/[~]*|\[~]*)(w)+)|[.](w)+)*(((([?](w)+){1}[=]*))*((w)+){1}([&](w)+[=](w)+)*)*)" 
  •  '$str = re.Replace($str,"$2") 
  •  're.Pattern="[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)](.[^[]*)[/SHADOW]" 
  •  '$str=re.Replace($str,"$4
  • ") 
  •  're.Pattern="[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)](.[^[]*)[/GLOW]" 
  •  '$str=re.Replace($str,"$4
  • ") 
  • */ 
  • ?>
  • 分享到:
    php模板 - php高级应用
    php模板 模板其实就是php和html的分离,有人也说mvc啥的,php处理程序,把动态内容保存到变量里面,然后通过模板输出这些变量的内容,这就是模板.你可以 $rows = $db->getAll($sql);require "tpl.html"; 来输出,你也可以: $tpl->setVar("rows",$rows);$tpl->display("tpl.html"); 来输出...
    php 分析rss代码一段 - php高级应用
    php 分析rss代码一段  
    •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
    • 在这里……