ubb解析出什么问题了,请帮忙!

yxflove 2003-12-15 03:36:00
昨天,我用了一下www.phpe.net中一个ubb。。可是出现了这样的错误。

ubb来源:http://www.phpe.net/?n=Source&file=inc/function.inc.php

function ubbParse($txt, $coverhtml=0) {

if ($coverhtml == 0) $txt = nl2br(htmlspecialchars($txt)); //BR和HTML转换
//只转换BR,不转换HTML
if ($coverhtml == 1) {
if (!preg_match('/^<.+>$/s', $txt) && !preg_match('/<table.+<\/table>/is', $txt)) {
$txt = strip_tags($txt);
$txt = nl2br($txt);
}
}

// pre and quote
$txt = preg_replace( "#\[quote\](.+?)\[/quote\]#is", "<blockquote>\1</blockquote>", $txt );
$txt = preg_replace( "#\[code\](.+?)\[/code\]#is", "<p class='php'>\1</p>", $txt );

// Colors 支持篏套
while( preg_match( "#\[color=([^\]]+)\](.+?)\[/color\]#is", $txt ) ) {
$txt = preg_replace( "#\[color=([^\]]+)\](.+?)\[/color\]#is", "<span style='color:\1'>\2</span>", $txt );
}

// Align
$txt = preg_replace( "#\[center\](.+?)\[/center\]#is", "<center>\1</center>", $txt );
$txt = preg_replace( "#\[left\](.+?)\[/left\]#is", "<div align=left>\1</div>", $txt );
$txt = preg_replace( "#\[right\](.+?)\[/right\]#is", "<div align=right>\1</div>", $txt );

// Sub & sup
$txt = preg_replace( "#\[sup\](.+?)\[/sup\]#is", "<sup>\1</sup>", $txt );
$txt = preg_replace( "#\[sub\](.+?)\[/sub\]#is", "<sub>\1</sub>", $txt );

// email tags
// avenger@php.net Email me
$txt = preg_replace( "#\[email\](\S+?)\[/email\]#i" , "<a href='mailto:\1'>\1</a>", $txt );
$txt = preg_replace( "#\[email\s*=\s*\"\;([\.\w\-]+\@[\.\w\-]+\.[\.\w\-]+)\s*\"\;\s*\](.*?)\[\/email\]#i" , "<a href='mailto:\1'>\2</a>", $txt );
$txt = preg_replace( "#\[email\s*=\s*([\.\w\-]+\@[\.\w\-]+\.[\w\-]+)\s*\](.*?)\[\/email\]#i" , "<a href='mailto:\1'>\2</a>", $txt );

// url tags
// http://www.phpe.net Exceed PHP!
$txt = preg_replace( "#\[url\](\S+?)\[/url\]#i" , "<a href='\1' target='_blank'>\1</a>", $txt );
$txt = preg_replace( "#\[url\s*=\s*\"\;\s*(\S+?)\s*\"\;\s*\](.*?)\[\/url\]#i" , "<a href='\1' target='_blank'>\2</a>", $txt );
$txt = preg_replace( "#\[url\s*=\s*(\S+?)\s*\](.*?)\[\/url\]#i" , "<a href='\1' target='_blank'>\2</a>", $txt );

// Start off with the easy stuff
$txt = preg_replace( "#\[b\](.+?)\[/b\]#is", "<b>\1</b>", $txt );
$txt = preg_replace( "#\[i\](.+?)\[/i\]#is", "<i>\1</i>", $txt );
$txt = preg_replace( "#\[u\](.+?)\[/u\]#is", "<u>\1</u>", $txt );
$txt = preg_replace( "#\[s\](.+?)\[/s\]#is", "<s>\1</s>", $txt );

// Images
$txt = preg_replace( "#\[img\](.+?)\[/img\]#i", "<a href='\1' target='_blank'><img alt='Click to fullsize' src='\1' border='0' onload='javascript:if(this.width>500) this.width=500' align='center' hspace='10' vspace='10'></a><br />", $txt );

// Attach
$txt = preg_replace( "#\[attach\s*=\s*\"\;\s*(\S+?)\s*\"\;\s*\](.*?)\[\/attach\]#i" , "<a href='\2' target='_blank'><b>相关附件:</b>\1</a>", $txt );
$txt = preg_replace( "#\[attach\s*=\s*(\S+?)\s*\](.*?)\[\/attach\]#i" , "<a href='\2' target='_blank'><b>相关附件:</b>\1</a>", $txt );

// Iframe
$txt = preg_replace( "#\[iframe\](.+?)\[/iframe\]#i", "<div align='center'><iframe src='\1' style='width:96%;height:400px'></iframe><br clear='all'><a href='\1' target='_blank'>在新窗口打开链接</a></div>", $txt );

// (c) (r) and (tm)
$txt = preg_replace( "#\(c\)#i" , "©" , $txt );
$txt = preg_replace( "#\(tm\)#i" , "™" , $txt );
$txt = preg_replace( "#\(r\)#i" , "®" , $txt );

return $txt;
}



下面是参考:http://www.phpe.net/?n=Source&file=article_show.php





$SQL = 'SELECT * FROM article WHERE article_id='.$a_num;
$db->query($SQL) or die('Query Error!');
if($db->num_rows()==0) { header("location:/");}
$db->next_obj();
  $article_title = myoutput($records->article_title);
$article_from = $records->article_from;
$article_author = $records->article_author;
$article_date = $records->article_date;

//文章格式处理
if (preg_match('/\[code\].+\[\/code\]/i', $records->article_content) || !preg_match('/<\s*(p|br)\s*>/is', $records->article_content))
$records->article_content = ubbParse($records->article_content);
 
echo $records->article_content;


得到了这样的不知所以的东西:

  











不用格式化如:<b> </b> <color> </color>的时候显示为正常的。。

在线等你帮忙啦!!
...全文
51 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yxflove 2004-01-09
  • 打赏
  • 举报
回复
re re
yxflove 2003-12-15
  • 打赏
  • 举报
回复
石沉大海了。。反对!!我反对啊。。。。。
yxflove 2003-12-15
  • 打赏
  • 举报
回复
约,在这个上面还不能显示。。

我贴出代码显示后的代码得了

<td width=580 style="word-wrap:break-word; font-size: 14px"><br><div align=left></div><br />
<br />
<br />
<span style='color:'></span><br />
<br />
<b></b><br />
<br />
<br />
<blockquote></blockquote></td>

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧