花魁直播高品质美女在线视频互动社区 - 花魁直播官方版

 歡迎來到素材無憂網(wǎng),按 + 收藏我們
登錄 注冊(cè) 退出 找回密碼

discuz x帖子內(nèi)容[attach]轉(zhuǎn)html

時(shí)間: 2019-05-29 11:11 閱讀: 作者:素材無憂網(wǎng)

之前用過
{echo discuzcode($value['message'], 0, 0, 0, 1, 1, 0, 0, 0, 0, 0);}
或者
require_once libfile('function/discuzcode');
{echo discuzcode($value['message']);}

能轉(zhuǎn)大部分UBB,但是[attach]轉(zhuǎn)不了。

下面是來自網(wǎng)絡(luò)的代碼,針對(duì)attach。
我用的時(shí)候做了一些修改。

<?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>';
}
}

?>


條件where b.pid=$pid,如果只調(diào)用主題帖內(nèi)容,改為where a.tid=$tid and b.first=1。
$pid或$tid使用時(shí)需要先獲得。

在調(diào)用帖子內(nèi)容時(shí),另外涉及到權(quán)限問題,如密碼、隱藏內(nèi)容、查看權(quán)限、主題售價(jià)等等。

版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!

轉(zhuǎn)載請(qǐng)注明: discuz x帖子內(nèi)容[attach]轉(zhuǎn)html

標(biāo)簽:  
相關(guān)文章
模板推薦