当前位置:Gxlcms > PHP教程 > 论坛里有人熟悉discuzX3.1吗?怎样将主题内容完整的显示出来

论坛里有人熟悉discuzX3.1吗?怎样将主题内容完整的显示出来

时间:2021-07-01 10:21:17 帮助过:32人阅读

论坛里有人熟悉discuz X3.1吗?怎样将主题内容完整的显示出来。


主题容易读出来forum_thread表就行了,但容易表forum_post里的内容不容易读出来呀。

毕竟里面含有[attach]4[/attach][img=500,666]http://pic.qiushibaike.com/system/pictures/5726/57264521/medium/app57264521.jpg[/img]

等,杂七杂八的数据。

人家官方不交流代码,只交流怎样安装。我晕倒了。只能想到CSDN来了,看看有人能不能搞定这个。


回复讨论(解决方案)

论坛里有人熟悉discuz X3.1吗?怎样将主题内容完整的显示出来。


主题容易读出来forum_thread表就行了,但容易表forum_post里的内容不容易读出来呀。

毕竟里面含有[attach]4[/attach][img=500,666]http://pic.qiushibaike.com/system/pictures/5726/57264521/medium/app57264521.jpg[/img]

等,杂七杂八的数据。

人家官方不交流代码,只交流怎样安装。我晕倒了。只能想到CSDN来了,看看有人能不能搞定这个。


人家的代码本身就含有一个这样的转换函数

@chinmo 版主

关键是我找到discuzcode()、parseattach()解析函数后,似乎没用。目前还在找原因。

@chinmo 版主

关键是我找到discuzcode()、parseattach()解析函数后,似乎没用。目前还在找原因。


晕死,你直接到他的帖子内容页去找不就知道他用的什么函数了?这还纠结什么

@chinmo

大版主呀,帖子内容应该是source\module\forum\forum_viewthread.php这个文件

可我找来找去,感觉就只有这两个函数相关。但还没有起到作用。

找了两天,晕死

@chinmo

大版主呀,帖子内容应该是source\module\forum\forum_viewthread.php这个文件

可我找来找去,感觉就只有这两个函数相关。但还没有起到作用。

找了两天,晕死


你再他模板找干嘛,DZ的他基本都是用$post这个数组保存数据的,你在他的控制器文件里输出这个数组就知道是哪个字段保存着文章内容了,然后你在在他的控制器里查找他对这个字段所用的处理函数不就可以了

做程序这点最起码的查找能力应该有的吧

@chinmo

大版主呀,我肯定不会去模板层找了,真的没有你想象的那么简单,我用的是discuz X3.1utf8版本。

帖子内容应该是source\module\forum\forum_viewthread.php这个文件

大概903行左右:
parseattach($_G['forum_attachpids'], $_G['forum_attachtags'], $postlist, $skipaids);

用来解析附件的。

大概是在1228行:
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $_G['forum']['allowsmilies'], $forum_allowbbcode, ($_G['forum']['allowimgcode'] && $_G['setting']['showimages'] ? 1 : 0), $_G['forum']['allowhtml'], ($_G['forum']['jammer'] && $post['authorid'] != $_G['uid'] ? 1 : 0), 0, $post['authorid'], $_G['cache']['usergroups'][$post['groupid']]['allowmediacode'] && $_G['forum']['allowmediacode'], $post['pid'], $_G['setting']['lazyload'], $post['dbdateline'], $post['first']);

用来解析内容的

但不晓得为什么就是不成功。

discuzcode 就是了用的这个函数
不成功的话
最简单的排查就是在这个函数里断句输出,看看他在那里替换不成功

这样也可以找出你具体是在什么环节上弄错了

各路PHP牛人,我把代码奉上:
define('APPTYPEID', 2);
define('CURSCRIPT', 'forum');

require './source/class/class_core.php';
require './source/function/function_forum.php';

$cachelist = array();
C::app()->cachelist = $cachelist;
C::app()->init();



//$navtitle = str_replace('{bbname}', $_G['setting']['bbname'], $_G['setting']['seotitle']['forum']);
//$_G['setting']['threadhidethreshold'] = 1;


//$query = C::t('forum_thread')->fetch_all_for_guide1($view, $limittid, $tids, $_G['setting']['heatthread']['guidelimit'], $dateline);

//$query = C::t('forum_thread')->fetch_all_search('', 'forum_thread', 0,'', '', '');;
//print_r($query);

require_once libfile('function/discuzcode');
require_once libfile('function/attachment');
require_once libfile('function/forum');
$sql = "SELECT a.*, b.message,b.htmlon,b.bbcodeoff,b.smileyoff,b.parseurloff,b.pid,b.first FROM ".DB::table('forum_thread')." a left join ".DB::table('forum_post')." b on a.authorid=b.authorid and a.tid=b.tid and b.first=1 WHERE 1=1 AND a.heats>=1" ;
$sql = "SELECT a.*, b.message,b.htmlon,b.bbcodeoff,b.smileyoff,b.parseurloff,b.pid,b.first FROM ".DB::table('forum_thread')." a left join ".DB::table('forum_post')." b on a.authorid=b.authorid and a.tid=b.tid and b.first=1 WHERE a.tid>0 AND a.heats>=0 ORDER BY a.lastpost DESC LIMIT 600";
$query = DB::fetch_all($sql);
$postlist = array();
foreach($query as $post){
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $_G['forum']['allowsmilies'], $forum_allowbbcode, ($_G['forum']['allowimgcode'] && $_G['setting']['showimages'] ? 1 : 0), $_G['forum']['allowhtml'], ($_G['forum']['jammer'] && $post['authorid'] != $_G['uid'] ? 1 : 0), 0, $post['authorid'], $_G['cache']['usergroups'][$post['groupid']]['allowmediacode'] && $_G['forum']['allowmediacode'], $post['pid'], $_G['setting']['lazyload'], $post['dbdateline'], $post['first']);

$_G['forum_attachpids'][] = $post['pid'];
if(preg_match_all("/\[attach\](\d+)\[\/attach\]/i", $post['message'], $matchaids)) {
$_G['forum_attachtags'][$post['pid']] = $matchaids[1];
}
$postlist[$post['pid']] = $post;
}

parseattach($_G['forum_attachpids'], $_G['forum_attachtags'], $postlist);

print_r($postlist);

?>

死活找不到那里有问题。

形如[img=500,666]http://pic.qiushibaike.com/system/pictures/5726/57264521/medium/app57264521.jpg[/img]
这样的是 ubb 代码
你可以找到 ubb 解码程序相关的部分切入
他好像是 bbcode 类

我也是跟lz一样,找到类似函数后没法解析了。这里看来大神没空解释这个问题

人气教程排行