哪位有写好的ubb转换函数分享一下,谢谢 哪位有写好的ubb转换函数分享一下,谢谢由于现在急用,来不及写了,请有的朋友发一下,谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 php扩展,编好就能直接用,php手册里面有说明 http://www.phpclasses.org/browse/package/818.html 谢谢,同时也分享一下我刚才从dz论坛上扒下来的一段html转换为ubb的函数,但在源码里面没有找到ubb->html转换的函数,有知道的朋友告诉一下函数名字,我再搜索一下function html2bbcode($text) { $text = strip_tags($text, '<table><tr><td><b><strong><i><em><u><a><div><span><p><strike><blockquote><ol><ul><li><font><img><br><br/><h1><h2><h3><h4><h5><h6><script>'); if(ismozilla()) { $text = preg_replace("/(?<!<br>|<br \/>|\r)(\r\n|\n|\r)/", ' ', $text); } $pregfind = array( "/<script.*>.*<\/script>/siU", '/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', "/(\r\n|\n|\r)/", "/<table([^>]*(width|background|background-color|bgcolor)[^>]*)>/siUe", "/<table.*>/siU", "/<tr.*>/siU", "/<td>/i", "/<td(.+)>/siUe", "/<\/td>/i", "/<\/tr>/i", "/<\/table>/i", '/<h([0-9]+)[^>]*>(.*)<\/h\\1>/siU', "/<img[^>]+smilieid=\"(\d+)\".*>/esiU", "/<img([^>]*src[^>]*)>/eiU", "/<a\s+?name=.+?\".\">(.+?)<\/a>/is", "/<br.*>/siU", "/<span\s+?style=\"float:\s+(left|right);\">(.+?)<\/span>/is", ); $pregreplace = array( '', '', '', "tabletag('\\1')", '[table]', '[tr]', '[td]', "tdtag('\\1')", '[/td]', '[/tr]', '[/table]', "[size=\\1]\\2[/size]\n\n", "smileycode('\\1')", "imgtag('\\1')", '\1', "\n", "[float=\\1]\\2[/float]", ); $text = preg_replace($pregfind, $pregreplace, $text); $text = recursion('b', $text, 'simpletag', 'b'); $text = recursion('strong', $text, 'simpletag', 'b'); $text = recursion('i', $text, 'simpletag', 'i'); $text = recursion('em', $text, 'simpletag', 'i'); $text = recursion('u', $text, 'simpletag', 'u'); $text = recursion('a', $text, 'atag'); $text = recursion('font', $text, 'fonttag'); $text = recursion('blockquote', $text, 'simpletag', 'indent'); $text = recursion('ol', $text, 'listtag'); $text = recursion('ul', $text, 'listtag'); $text = recursion('div', $text, 'divtag'); $text = recursion('span', $text, 'spantag'); $text = recursion('p', $text, 'ptag'); $pregfind = array("/(?<!\r|\n|^)\[(\/list|list|\*)\]/", "/<li>(.*)((?=<li>)|<\/li>)/iU", "/<p.*>/iU", "/<p><\/p>/i", "/(<a>|<\/a>|<\/li>)/is", "/<\/?(A|LI|FONT|DIV|SPAN)>/siU", "/\[url[^\]]*\]\[\/url\]/i", "/\[url=javascript:[^\]]*\](.+?)\[\/url\]/is"); $pregreplace = array("\n[\\1]", "\\1\n", "\n", '', '', '', '', "\\1"); $text = preg_replace($pregfind, $pregreplace, $text); $strfind = array(' ', '<', '>', '&'); $strreplace = array(' ', '<', '>', '&'); $text = str_replace($strfind, $strreplace, $text); return trim($text);} 如何判断字符串中是否含有数组的某个元素? 新手求教文件上传问题 mysql数据库连接问题 我插入数据成功可mysql_query还是返回false php 生成html代码的问题 菜鸟紧急求助!!!很简单的! 如何对TEXT类型字段的分次处理 一个读取文本文件内容的问题! 为什么apache不能以模块方式安装??急!在线等 关于From,我快没有信心了 用mssql_fetch_object显示表内记录只显示一条 php语法里的:是什么意思
function html2bbcode($text) { $text = strip_tags($text, '<table><tr><td><b><strong><i><em><u><a><div><span><p><strike><blockquote><ol><ul><li><font><img><br><br/><h1><h2><h3><h4><h5><h6><script>'); if(ismozilla()) {
$text = preg_replace("/(?<!<br>|<br \/>|\r)(\r\n|\n|\r)/", ' ', $text);
} $pregfind = array(
"/<script.*>.*<\/script>/siU",
'/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i',
"/(\r\n|\n|\r)/",
"/<table([^>]*(width|background|background-color|bgcolor)[^>]*)>/siUe",
"/<table.*>/siU",
"/<tr.*>/siU",
"/<td>/i",
"/<td(.+)>/siUe",
"/<\/td>/i",
"/<\/tr>/i",
"/<\/table>/i",
'/<h([0-9]+)[^>]*>(.*)<\/h\\1>/siU',
"/<img[^>]+smilieid=\"(\d+)\".*>/esiU",
"/<img([^>]*src[^>]*)>/eiU",
"/<a\s+?name=.+?\".\">(.+?)<\/a>/is",
"/<br.*>/siU",
"/<span\s+?style=\"float:\s+(left|right);\">(.+?)<\/span>/is",
);
$pregreplace = array(
'',
'',
'',
"tabletag('\\1')",
'[table]',
'[tr]',
'[td]',
"tdtag('\\1')",
'[/td]',
'[/tr]',
'[/table]',
"[size=\\1]\\2[/size]\n\n",
"smileycode('\\1')",
"imgtag('\\1')",
'\1',
"\n",
"[float=\\1]\\2[/float]",
);
$text = preg_replace($pregfind, $pregreplace, $text); $text = recursion('b', $text, 'simpletag', 'b');
$text = recursion('strong', $text, 'simpletag', 'b');
$text = recursion('i', $text, 'simpletag', 'i');
$text = recursion('em', $text, 'simpletag', 'i');
$text = recursion('u', $text, 'simpletag', 'u');
$text = recursion('a', $text, 'atag');
$text = recursion('font', $text, 'fonttag');
$text = recursion('blockquote', $text, 'simpletag', 'indent');
$text = recursion('ol', $text, 'listtag');
$text = recursion('ul', $text, 'listtag');
$text = recursion('div', $text, 'divtag');
$text = recursion('span', $text, 'spantag');
$text = recursion('p', $text, 'ptag'); $pregfind = array("/(?<!\r|\n|^)\[(\/list|list|\*)\]/", "/<li>(.*)((?=<li>)|<\/li>)/iU", "/<p.*>/iU", "/<p><\/p>/i", "/(<a>|<\/a>|<\/li>)/is", "/<\/?(A|LI|FONT|DIV|SPAN)>/siU", "/\[url[^\]]*\]\[\/url\]/i", "/\[url=javascript:[^\]]*\](.+?)\[\/url\]/is");
$pregreplace = array("\n[\\1]", "\\1\n", "\n", '', '', '', '', "\\1");
$text = preg_replace($pregfind, $pregreplace, $text); $strfind = array(' ', '<', '>', '&');
$strreplace = array(' ', '<', '>', '&');
$text = str_replace($strfind, $strreplace, $text); return trim($text);
}