您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php把ubb代码转换成html

2025/11/7 7:56:29发布10次查看
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,,$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
,$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 = ;
  $text =@preg_replace($pattern, $replacement, $text);
  $str  = $text;
  $pattern='#\[flash=(\d+),(\d+)\](.+)\[/flash\]#';
  $last =
[全屏欣赏 提醒: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));
}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product