以下是配合上面分離發表與回覆的功能\r
用途是以發表數為條件的隱藏文章
DEMO:
http://emn178.idv.st
代碼: 選擇全部
===============================================
開啟
bbcode.php
===============================================
尋找\r
$bbcode_tpl['email'] = str_replace('{EMAIL}', '\\\1', $bbcode_tpl['email']);
===============================================
後面加上
$bbcode_tpl['post'] = str_replace('{HTEXTE}', '\\\2', $bbcode_tpl['post']);
$bbcode_tpl['hpost'] = str_replace('{NEEDPOSTS}', '\\\1', $bbcode_tpl['hpost']);
===============================================
尋找\r
/**
* Does second-pass bbencoding. This should be used before displaying the message in
* a thread. Assumes the message is already first-pass encoded, and we are given the
* correct UID as used in first-pass encoding.
*/
===============================================
前面加上
\n
function bbencode_post_pass_first($text,$uid,$x)
{
$needposts = preg_replace("#(.*?)\[post=([0-9]?[0-9]?[0-9]):$uid\](.*?)\[/post:$uid\](.*?)#si","\\\2 ", $text);
$poststropsn = strpos($needposts, " ");
$needposts = substr($needposts,0,$poststropsn);
$posttext1 = "[post=" . $needposts . ":$uid]";
$posttext2 = "[/post:$uid]";
$poststrops1 = strpos($text, $posttext1);
$poststrops2 = strpos($text, $posttext2);
if($x == 0)
{
if($poststrops1 > -1 && $poststrops2 > -1)
{
return TRUE;
}
else
{
return FALSE;
}
}
else
return $needposts;
}
function bbencode_post_pass($text,$uid,$poster_id)
{
global $bbcode_tpl,$userdata;
$user_posts = $userdata['user_posts'] - $userdata['user_reply'];
$needposts = preg_replace("#(.*?)\[post=([0-9]?[0-9]?[0-9]):$uid\](.*?)\[/post:$uid\](.*?)#si","\\\2 ", $text);
$poststropsn = strpos($needposts, " ");
$needposts = substr($needposts,0,$poststropsn);
// pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
// This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
$text = " " . $text;
// Patterns and replacements for URL and email tags..
$patterns = array();
$replacements = array();
if ( $user_posts >= $needposts || $userdata['user_id'] == $poster_id)
{
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['post'];
}
else
{
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['hpost'];
}
$text = preg_replace($patterns, $replacements, $text);
$text = substr($text, 1);
return $text;
}
===============================================
尋找\r
===============================================
// [stream] and [/stream] for streaming audio.
// This one gets first-passed..
$patterns[] = "#\[stream:$uid\](.*?)\[/stream:$uid\]#si";
$replacements[] = $bbcode_tpl['stream'];
===============================================
下面加入\r
===============================================
// [post]text[/post] code..
$patterns[] = "#\[post=([0-9]?[0-9]?[0-9]):$uid\](.*?)\[/post:$uid\]#si";
$replacements[] = $bbcode_tpl['post'];
===============================================
開啟
bbcode.tpl
===============================================
最前面加上
<!-- BEGIN post -->
</span>
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
<td><span class="genmed"><b>以下為發表數隱藏文章內容,看完後請務必修改剛剛的留言,說一下心得感想喔....</b></span></td>
</tr>
<tr>
<td class="quote">
{HTEXTE}
</td>
</tr>
</table>
<span class="postbody">
<!-- END post -->
<!-- BEGIN hpost -->
</span>
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
<td><span class="genmed"><b>神秘內容:</b></span></td>
</tr>
<tr>
<td class="quote">
<center>--- 假如已是*註冊會員*:那麼您得發表總數必須達到<font color="#FF0000">{NEEDPOSTS}篇</font>才能看到完整的文章! ---<p>上傳很辛苦,請給發表者一點鼓勵吧!</center>
</td>
</tr>
</table>
<span class="postbody">
<!-- END hpost -->
===============================================
開啟
posting.php
===============================================
尋找\r
if( !$html_on )
{
if( $user_sig != '' || !$userdata['user_allowhtml'] )
{
$user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', '<\2>', $user_sig);
}
}
===============================================
後面加上
//post mod
$setpost = FALSE;
$setpost = bbencode_post_pass_first($preview_message,$bbcode_uid,0);
//post mod
===============================================
尋找\r
$user_sig = bbencode_second_pass($user_sig, $userdata['user_sig_bbcode_uid']);
===============================================
後面加上
if($setpost == true)
$user_sig = bbencode_post_pass($user_sig,$userdata['user_sig_bbcode_uid'],$post_data['poster_id']);
===============================================
尋找\r
$preview_message = bbencode_second_pass($preview_message, $bbcode_uid);
===============================================
後面加上
if($setpost == true)
$preview_message = bbencode_post_pass($preview_message,$bbcode_uid,$post_data['poster_id']);
===============================================
開啟
viertopic.php
===============================================
尋找\r
if ( $board_config['allow_bbcode'] )
===============================================
後面加上
//post mod
$setpost = FALSE;
$setpost = bbencode_post_pass_first($postrow[$i]['post_text'],$bbcode_uid,0);
//post mod
===============================================
尋找\r
$user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $user_sig);
===============================================
後面加上
if($setpost == TRUE)
$user_sig = bbencode_post_pass($user_sig,$bbcode_uid,$poster_id);
===============================================
尋找\r
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
===============================================
後面加上
if($setpost == TRUE)
$message = bbencode_post_pass($message,$bbcode_uid,$poster_id);
===============================================
隱藏附加檔案的話:
===============================================
尋找\r
display_post_attachments($postrow[$i]['post_id'], $postrow[$i]['post_attachment']);
===============================================
改成
if($setpost == true)
{
$needposts = bbencode_post_pass_first($postrow[$i]['post_text'],$bbcode_uid,1);
if($postrow[$i]['user_posts'] >= $needposts || $postrow[$i]['poster_id'] == $userdata['user_id'])
display_post_attachments($postrow[$i]['post_id'], $postrow[$i]['post_attachment']);
}
else
display_post_attachments($postrow[$i]['post_id'], $postrow[$i]['post_attachment']);
===============================================
開啟
include/topic_review.php
===============================================
尋找\r
if ( $row = $db->sql_fetchrow($result) )
{
===============================================
下面加入\r
//post mod
$setpost = false;
$setpost = bbencode_post_pass_first($row['post_text'],$bbcode_uid,0);
//post mod
===============================================
尋找\r
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
$message = bbencode_third_pass($message, $bbcode_uid, $valid);
===============================================
下面加入\r
if($setpost == true)
$message = bbencode_post_pass($message,$bbcode_uid,$poster_id);
===============================================
開啟
language/.../lang_main.php
===============================================
搜索\r
$lang['bbcode_sc_help'] = '你可以使用此功能產生不同的表情符號';
===============================================
後面加上
$lang['bbcode_post_help'] = "隱藏內容:[post=發表數]隱藏文字內容[/post]";
註:如果有使用熱鍵的話可以自己加上去\r
===============================================
使用友善列印的話:
代碼: 選擇全部
===============================================
開啟
printview.php
===============================================
尋找\r
for($i = 0; $i < $total_posts; $i++)
{
===============================================
後面加上
//post mod
$setpost = false;
$setpost = bbencode_post_pass_first($postrow[$i]['post_text'],$postrow[$i]['bbcode_uid'],0);
//post mod
===============================================
尋找\r
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
===============================================
後面加上
if($setpost == true)
$message = bbencode_post_pass($message,$bbcode_uid,$poster_id);
===============================================
使用儲存主題的話:
代碼: 選擇全部
===============================================
開啟
export.php
===============================================
尋找\r
for($i = 0; $i < $total_posts; $i++)
{
===============================================
後面加上
//post mod
$setpost = false;
$setpost = bbencode_post_pass_first($postrow[$i]['post_text'],$postrow[$i]['bbcode_uid'],0);
//post mod
===============================================
尋找\r
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
===============================================
後面加上
if($setpost == true)
$message = bbencode_post_pass($message,$bbcode_uid,$poster_id);
===============================================
使用新聞快報的話:
代碼: 選擇全部
===============================================
開啟
includes/news.php
===============================================
尋找\r
$message = str_replace("
", "
<br />
", $message);
===============================================
前面加上
//post mod
$setpost = false;
$setpost = bbencode_post_pass_first($news[$i]['post_text'],$bbcode_uid,0);
//post mod
===============================================
後面加上
if($setpost == true)
$message = bbencode_post_pass($message,$bbcode_uid,$poster_id);
===============================================
使用主題預覽的話:
代碼: 選擇全部
===============================================
開啟
viewforum.php
===============================================
尋找\r
$topic_content = strip_tags($topic_content);
===============================================
後面加上
//post mod
$setpost = false;
$setpost = bbencode_post_pass_first($topic_rowset[$i]['post_text'],$bbcode_uid,0);
$needposts = bbencode_post_pass_first($topic_rowset[$i]['post_text'],$bbcode_uid,1);
$posttext1 = "[post=" . $needposts . ":" . $bbcode_uid . "]";
$posttext2 = "[/post:" . $bbcode_uid ."]";
$poststrops1 = strpos($topic_content, $posttext1);
$poststrops2 = strpos($topic_content, $posttext2);
$postcontent1 = substr($topic_content,0,$poststrops1);
$postcontent2 = substr($topic_content,$poststrops2 + 18,strlen($topic_content) - ($poststrops2 + 18));
$postcontent = substr($topic_content,$poststrops1+strlen($needposts)+17,$poststrops3 - ($poststrops1+strlen($needposts)+17));
if($postcontent1 != "")
$postcontent1 = $postcontent1 . "
";
if($postcontent2 != "")
$postcontent2 = "
" . $postcontent2;
if($setpost == true)
{
if($userdata['user_posts'] >= $needposts || $userdata['user_id'] == $topic_rowset[$i]['poster_id'])
$topic_content = $postcontent1 . $lang['PostHideShowStart'] . $postcontent . $lang['PostHideShowEnd'] . $postcontent2;
else
$topic_content = $postcontent1 . $lang['PostHide'] . $postcontent2;
}
//post mod
===============================================
開啟
language/.../lang_main.php
===============================================
搜索\r
//
// That's all, Folks!
// -------------------------------------------------
===============================================
前面加上
$lang['PostHideShowStart'] = "***===以下為發表數隱藏文章內容===***
";
$lang['PostHideShowEnd'] = "
***===以上為發表數隱藏文章內容===***";
$lang['PostHide'] = "***===內文隱藏===***
神秘內容:
你必須達到規定的發表數才能觀看
***===內文隱藏===***";
===============================================
使用new mod的話:
代碼: 選擇全部
===============================================
開啟
fetchposts.php
===============================================
尋找\r
//
// do a little magic
// note: part of this comes from mds' news script and some additional magics from Smartor
//
===============================================
前面加上
//post mod
$setpost = false;
$setpost = bbencode_post_pass_first($posts[$i]['post_text'],$posts[$i]['bbcode_uid'],0);
//post mod
===============================================
尋找\r
if (($text_length == 0) or (strlen($posts[$i]['post_text']) <= $text_length))
{
$posts[$i]['post_text'] = bbencode_second_pass($posts[$i]['post_text'], $posts[$i]['bbcode_uid']);
$posts[$i]['striped'] = 0;
}
else
{
$posts[$i]['post_text'] = bbencode_strip($posts[$i]['post_text'], $posts[$i]['bbcode_uid']);
$posts[$i]['post_text'] = substr($posts[$i]['post_text'], 0, $text_length) . '...';
$posts[$i]['striped'] = 1;
}
===============================================
改成
===============================================
if (($text_length == 0) or (strlen($posts[$i]['post_text']) <= $text_length))
{
$posts[$i]['post_text'] = bbencode_second_pass($posts[$i]['post_text'], $posts[$i]['bbcode_uid']);
$posts[$i]['striped'] = 0;
}
else
{
if($setpost == false)
{
$posts[$i]['post_text'] = bbencode_strip($posts[$i]['post_text'], $posts[$i]['bbcode_uid']);
$posts[$i]['post_text'] = substr($posts[$i]['post_text'], 0, $text_length) . '...';
}
else
{
$posttext2 = "[/post:" . $posts[$i]['bbcode_uid'] . "]";
$poststrops2 = strpos($posts[$i]['post_text'], $posttext2);
$px = $poststrops2 + 18;
if($sethide == true && $setpost == true)
{
if($text_length > $px)
$posts[$i]['post_text'] = substr($posts[$i]['post_text'], 0, $text_length) . '...';
else
$posts[$i]['post_text'] = substr($posts[$i]['post_text'], 0, $text_length) . '...' . "[/post:" . $posts[$i]['bbcode_uid'] . "]";
}
}
$posts[$i]['striped'] = 1;
}
===============================================
尋找\r
$posts[$i]['post_text'] = nl2br($posts[$i]['post_text']);
===============================================
後面加上
if($setpost == true)
$posts[$i]['post_text'] = bbencode_post_pass($posts[$i]['post_text'],1,$posts[$i]['poster_id']);
===============================================
以下為BBCode按鈕,但僅適用plus1.3或有安裝此mod的人\r
代碼: 選擇全部
===============================================
開啟
posting.php
===============================================
尋找\r
// EASYMOD-begin
//NOTE: the first element of each array must be '' Add new elements AFTER the ''
$EMBB_keys = array('','e','k','m','g','s','h','d','v','j','n','x','y','z') ;
$EMBB_widths = array('','52','52','52','52','52','52','52','52','52','52','52','52','52') ;
$EMBB_values = array('','Fade','Scroll','Flash','Glow','Shadow','Highlight','Align','FlipV','FlipH','Stream','Left','Right','PHP') ;
===============================================
再第一行後面加上
,'Post'
註:此為熱鍵,如果已經不夠了才用這個
===============================================
第二行
,'52'
===============================================
第三行
,'Post'
===============================================
使變成
// EASYMOD-begin
//NOTE: the first element of each array must be '' Add new elements AFTER the ''
$EMBB_keys = array('','e','k','m','g','s','h','d','v','j','n','x','y','z','Post') ;
$EMBB_widths = array('','52','52','52','52','52','52','52','52','52','52','52','52','52','52') ;
$EMBB_values = array('','Fade','Scroll','Flash','Glow','Shadow','Highlight','Align','FlipV','FlipH','Stream','Left','Right','PHP','Post') ;
===============================================
尋找\r
'L_BBCODE_SC_HELP' => $lang['bbcode_sc_help'],
===============================================
後面加上
'L_BBCODE_POST_HELP' => $lang['bbcode_post_help'],
===============================================
開啟
posting_body.tpl
===============================================
尋找\r
sc_help = "{L_BBCODE_SC_HELP}";
===============================================
後面加上
Post_help = "{L_BBCODE_POST_HELP}";
===============================================
尋找\r
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','
','
','
','[img]','[/img]','
','','[fade]','[/fade]','[scroll]','[/scroll]','[flash width=100 height=100]','[/flash]','[glow=red]','[/glow]','[shadow=red]','[/shadow]','[highlight=red]','[/highlight]','[align=center]','[/align]','[flipv]','[/flipv]','[fliph]','[/fliph]','[stream]','[/stream]','[left]','[/left]','[right]','[/right]','[php]','[/php]');
===============================================
後面加上
,'[post=10]','[/post]'
===============================================
變成
bbtags = new Array('
','','
','','
','','[quote]','[/quote]','
','
','
','[img]','[/img]','
','','[fade]','[/fade]','[scroll]','[/scroll]','[flash width=100 height=100]','[/flash]','[glow=red]','[/glow]','[shadow=red]','[/shadow]','[highlight=red]','[/highlight]','[align=center]','[/align]','[flipv]','[/flipv]','[fliph]','[/fliph]','[stream]','[/stream]','[left]','[/left]','[right]','[/right]','[php]','[/php]','[post=10]','[/post]');
===============================================
[/code]