discuz

推荐列表 站点导航

当前位置:首页 > 建站教程 > discuz >

discuz x帖子内容[attach]转html

来源:网络整理  作者:网络  发布时间:2020-12-12 16:20
之前用过 {echo discuzcode($value[message], 0, 0, 0, 1, 1, 0, 0, 0, 0, 0);} 或者 require_once libfile(function/discuzcode); {echo discuzcode($valu...
在调用帖子内容时,另外涉及到权限问题,如密码、隐藏内容、查看权限、主题售价等等。
require_once libfile('function/discuzcode');
条件where b.pid=$pid,如果只调用主题帖内容,改为where a.tid=$tid and b.first=1。

我用的时候做了一些修改。
或者


{echo discuzcode($value['message'], 0, 0, 0, 1, 1, 0, 0, 0, 0, 0);}

之前用过
能转大部分UBB,但是[attach]转不了。
{echo discuzcode($value['message']);}

下面是来自网络的代码,针对attach。
<?php $thread_info = DB::fetch_first ( "select a.`tid`, a.`authorid`, a.`author`,a.`dateline`, a.`subject`, b.`message`,b.`pid`, c.`attachment` as thumb, c.`remote` from " . DB::table ( 'forum_thread' ) . " a left join " . DB::table ( 'forum_post' ) . " b on b.tid=a.tid left join " . DB::table ( 'forum_threadimage' ) . " c on c.tid=a.tid where b.pid=$pid"); require_once libfile ( 'function/discuzcode' ); $thread_info ['dateline'] = date ( "Y-m-d H:i:s", $thread_info ['dateline'] ); $thread_info ['message'] = discuzcode ( $thread_info ['message'] ); if (preg_match_all ( "/\[attach\](\d+)\[\/attach\]/i", $thread_info ['message'], $matchaids )) { $attach_ids = $matchaids [1]; } $attach_list = array (); foreach ( $attach_ids as $aid ) { $find = "/\[attach\]$aid\[\/attach\]/i"; $thread_info ['message'] = preg_replace ( $find, get_lw_attach_path ( $aid ), $thread_info ['message'], 1 ); $thread_info ['message'] = preg_replace ( $find, '', $thread_info ['message'] ); } function get_lw_attach_path($aid) { global $_G; $return = $filename = ''; if ($attach = C::t ( 'forum_attachment_n' )->fetch ( 'aid:' . $aid, $aid, array (1,- 1) )) { return get_lw_attach_path_str ( $attach ); } return $filename; } function get_lw_attach_path_str($attach) { global $_G; if (! $attach ['isimage']) { return '<a href="' . $_G ['siteurl'] . 'forum.php?mod=attachment&aid=' . aidencode ( $attach ['aid'] ) . '">' . $attach ['filename'] . '</a>'; } if ($attach ['remote']) { $imgurl = $_G ['setting'] ['ftp'] ['attachurl'] . 'forum/' . $attach ['attachment']; return '<p><img onclick="viewimage(this);" src="' . $imgurl . '" style="max-width:834px"/></p>'; } else { if (preg_match ( '/^(?!http:)/', $attach ['url'] )) { $attach ['url'] = $_G ['siteurl'] . 'data/attachment/forum/' . $attach ['url']; } $imgurl = $attach ['url'] . $attach ['attachment'] . ($_G ['gp_width'] ? '&width=' . $_G ['gp_width'] : '') . ($_G ['gp_height'] ? '&height=' . $_G ['gp_height'] : ''); return '<p><a href="' . $imgurl . '" target="_blank"><img height="320" width="320" src="' . $imgurl . '" /></a></p>'; } } ?>  
$pid或$tid使用时需要先获得。

相关热词: HTML discuz

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://www.juheyunku.com/jz/discuz/2986.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

discuz x帖子内容[attach]转html

2020-12-12 编辑:网络

在调用帖子内容时,另外涉及到权限问题,如密码、隐藏内容、查看权限、主题售价等等。
require_once libfile('function/discuzcode');
条件where b.pid=$pid,如果只调用主题帖内容,改为where a.tid=$tid and b.first=1。

我用的时候做了一些修改。
或者


{echo discuzcode($value['message'], 0, 0, 0, 1, 1, 0, 0, 0, 0, 0);}

之前用过
能转大部分UBB,但是[attach]转不了。
{echo discuzcode($value['message']);}

下面是来自网络的代码,针对attach。
<?php $thread_info = DB::fetch_first ( "select a.`tid`, a.`authorid`, a.`author`,a.`dateline`, a.`subject`, b.`message`,b.`pid`, c.`attachment` as thumb, c.`remote` from " . DB::table ( 'forum_thread' ) . " a left join " . DB::table ( 'forum_post' ) . " b on b.tid=a.tid left join " . DB::table ( 'forum_threadimage' ) . " c on c.tid=a.tid where b.pid=$pid"); require_once libfile ( 'function/discuzcode' ); $thread_info ['dateline'] = date ( "Y-m-d H:i:s", $thread_info ['dateline'] ); $thread_info ['message'] = discuzcode ( $thread_info ['message'] ); if (preg_match_all ( "/\[attach\](\d+)\[\/attach\]/i", $thread_info ['message'], $matchaids )) { $attach_ids = $matchaids [1]; } $attach_list = array (); foreach ( $attach_ids as $aid ) { $find = "/\[attach\]$aid\[\/attach\]/i"; $thread_info ['message'] = preg_replace ( $find, get_lw_attach_path ( $aid ), $thread_info ['message'], 1 ); $thread_info ['message'] = preg_replace ( $find, '', $thread_info ['message'] ); } function get_lw_attach_path($aid) { global $_G; $return = $filename = ''; if ($attach = C::t ( 'forum_attachment_n' )->fetch ( 'aid:' . $aid, $aid, array (1,- 1) )) { return get_lw_attach_path_str ( $attach ); } return $filename; } function get_lw_attach_path_str($attach) { global $_G; if (! $attach ['isimage']) { return '<a href="' . $_G ['siteurl'] . 'forum.php?mod=attachment&aid=' . aidencode ( $attach ['aid'] ) . '">' . $attach ['filename'] . '</a>'; } if ($attach ['remote']) { $imgurl = $_G ['setting'] ['ftp'] ['attachurl'] . 'forum/' . $attach ['attachment']; return '<p><img onclick="viewimage(this);" src="' . $imgurl . '" style="max-width:834px"/></p>'; } else { if (preg_match ( '/^(?!http:)/', $attach ['url'] )) { $attach ['url'] = $_G ['siteurl'] . 'data/attachment/forum/' . $attach ['url']; } $imgurl = $attach ['url'] . $attach ['attachment'] . ($_G ['gp_width'] ? '&width=' . $_G ['gp_width'] : '') . ($_G ['gp_height'] ? '&height=' . $_G ['gp_height'] : ''); return '<p><a href="' . $imgurl . '" target="_blank"><img height="320" width="320" src="' . $imgurl . '" /></a></p>'; } } ?>  
$pid或$tid使用时需要先获得。

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://www.juheyunku.com/jz/discuz/2986.shtml

相关文章

风云图片

推荐阅读

返回discuz频道首页