Home > php教程 > PHP源码 > body text

php把ubb代码转换成html

WBOY
Release: 2016-06-08 17:30:44
Original
1599 people have browsed it
<script>ec(2);</script>

php把ubb代码转换成html

function  ubb($Text) 
  {
  $Text=htmlspecialchars($Text);
  $Text=stripslashes($Text); 
  $Text=ereg_replace("\r\n","
",$Text);
  $Text=ereg_replace("\r","
",$Text);
  $Text=nl2br($Text);
  $Text=preg_replace("/\\t/is"," ",$Text);
  $Text=ereg_replace("  "," ",$Text); 
  $Text=preg_replace("/\[h1\](.+?)\[\/h1\]/is","

\\1

",$Text);
  $Text=preg_replace("/\[h2\](.+?)\[\/h2\]/is","

\\1

",$Text);
  $Text=preg_replace("/\[h3\](.+?)\[\/h3\]/is","

\\1

",$Text);
  $Text=preg_replace("/\[h4\](.+?)\[\/h4\]/is","

\\1

",$Text);
  $Text=preg_replace("/\[h5\](.+?)\[\/h5\]/is","
\\1
",$Text);
  $Text=preg_replace("/\[h6\](.+?)\[\/h6\]/is","
\\1
",$Text);
  $Text=preg_replace("/\[center\](.+?)\[\/center\]/is","
\\1
",$Text);
  $Text=preg_replace("/\[big\](.+?)\[\/big\]/is","\\1",$Text);
  $Text=preg_replace("/\[small\](.+?)\[\/small\]/is","\\1",$Text); 
  $Text=preg_replace("/\[url\](http:\/\/.+?)\[\/url\]/is","\\1",$Text);
  $Text=preg_replace("/\[url\](.+?)\[\/url\]/is","http://\\1",$Text);
  $Text=preg_replace("/\[url=(http:\/\/.+?)\](.*)\[\/url\]/is","\\2",$Text);
  $Text=preg_replace("/\[url=(.+?)\](.*)\[\/url\]/is","\\2",$Text);
  $Text=preg_replace("/\[img\](.+?)\[\/img\]/is","php把ubb代码转换成html",$Text);
  $Text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","\\2",$Text);
  $Text=preg_replace("/\[size=(.+?)\](.+?)\[\/size\]/is","\\2",$Text);
  $Text=preg_replace("/\[sup\](.+?)\[\/sup\]/is","\\1",$Text);
  $Text=preg_replace("/\[sub\](.+?)\[\/sub\]/is","\\1",$Text);
  $Text=preg_replace("/\[pre\](.+?)\[\/pre\]/is","
\\1
Copy after login
",$Text);
  $Text=preg_replace("/\[email\](.+?)\[\/email\]/is","\\1",$Text);
  $Text=preg_replace("/\[i\](.+?)\[\/i\]/is","\\1",$Text);
  $Text=preg_replace("/\[b\](.+?)\[\/b\]/is","\\1",$Text);
  $Text=preg_replace("/\[quote\](.+?)\[\/quote\]/is","
quote:
\\1
",  $Text);
  $pattern = "/(\[uploadimage\])(\d+),(.*)(\[\/uploadimage\])/U";
  $replacement = "php把ubb代码转换成html";
  $Text =@preg_replace($pattern, $replacement, $Text);
  $str  = $Text;
  $pattern='#\[flash=(\d+),(\d+)\](.+)\[/flash\]#';
  $last = "

     width=\"$2\" height=\"$1\">


  [全屏欣赏 提醒:Flash中可能包含不安全内容]
  
";
  $Text= preg_replace($pattern, $last, $str); 
  $mpg ="
   
  
  
  
  
  
  

  
";
  $Text =preg_replace('#\[mp=(\d+),(\d+)\](.+)\[/mp\]#', $mpg, $Text);     
  return @iconv('utf-8','gbk',@iconv('gbk','utf-8',$Text));
     
  }
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template