試試吧\r
DEMO:
http://emn178.idv.st
2004/4/5修正內容:
修正引言和和搜索使用者所有文章漏掉的部分,以及更正部分錯誤
修改的檔案posting.php,search.php,topic_review.php,viewforum.php
2004/4/6再次修改:
search.php部分少了一段程式碼\r
bbcode.php的部分有人提出新版的phpbb有些許不同
所以也一並更正了
2004/04/07 v1.3 修正內容:
bbcode.php,posting.php,viewforum部分修正了訪客部分的隱藏
bbcode.php部分新增可以設定最大最小的文章需求數\r
2004/04/07 v1.4 修正內容:
viewtopic.php部分修正了簽名檔顯示問題
2004/04/10 v1.5 修正內容:
bbcode.php部分修正了多重隱藏時,達到第一個隱藏條件會全部顯示的問題
2004/04/11 v1.6 修正內容:
bbcode.php部分再次修正了bug
新的版本請到\r
http://emn178.idv.st/
查詢
v1.6
代碼: 選擇全部
#################################################################
## Mod Title: 發表數隱藏文章(Post Topics Hide Mod)
## Mod Version: v1.6
## Author: emn178 - http://emn178.idv.st
##
## Description: 此Mod能夠將文章以觀看者的發表主題數(需配合區分主題與回覆Mod)
## 或總發表數(主題加回覆,可直接安裝),作為觀看文章的需求條件\r
## 必須達到指定的數量才能觀看文章
##
## Installation Level: 中
## Installation Time: 10 Minutes
## Files To Edit: 8-13
## include/bbcode.php
## include/topic_review.php
## language/.../lang_main.php
## posting.php
## viertopic.php
## search.php
## templates/你的風格/bbcode.tpl
## templates/你的風格/posting_body.tpl
## (include/news.php) for 新聞快報mod
## (printview.php) for 友善列印mod
## (export.php) for 儲存主題mod
## (fetchposts.php) for ezPortal mod
## (viewforum.php) for 主題預覽mod
##
## Included Files: N/A
#################################################################
#
#-----[ 開啟 ]------------------------------------------
#
include/bbcode.php
#
#-----[ 尋找 ]------------------------------------------
#
$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']);
#
#-----[ 尋找 ]------------------------------------------
#
/**
* 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 */
#
#-----[ 前面加上 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
function bbencode_post_pass_first($text,$uid,$x)
{
$needposts = preg_replace("#(.*?)\[post=(.*?):$uid\](.*?)\[/post:$uid\](.*?)#si","\\\2 ", $text);
$poststropsn = strpos($needposts, " ");
$needposts = substr($needposts,0,$poststropsn);
$tneedposts = $needposts;
if($needposts > 1000)
$needposts = 1000;
else if($needposts < 5 || $needposts/1 != $needposts)
$needposts = 5;
//註:> 1000和= 1000的1000是最大值, < 5和 = 5是最小值,改成你要的數值\r
$posttext1 = "[post=" . $tneedposts . ":$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'];
//註:如果要使用總發表數為條件或者未安裝區分主題與回覆Mod的話\r
//上面這行改成$user_posts = $userdata['user_posts'];
$needposts = preg_replace("#(.*?)\[post=(.*?):$uid\](.*?)\[/post:$uid\](.*?)#si","\\\2 ", $text);
if(!$needposts)
return $text;
$text = " " . $text;
$poststropsn = strpos($needposts, " ");
$needposts = substr($needposts,0,$poststropsn);
$posttext = "[/post:$uid]";
$poststrops = strpos($text, $posttext);
$text1 = substr($text,0,$poststrops+18);
$text2 = substr($text,$poststrops+18,strlen($text) - ($poststrops+18));
$text2 = bbencode_post_pass($text2,$uid,$poster_id);
$tneedposts = $needposts;
if($needposts > 1000)
$needposts = 1000;
else if($needposts < 5 || $needposts/1 != $needposts)
$needposts = 5;
//註:> 1000和= 1000的1000是最大值, < 5和 = 5是最小值,改成你要的數值\r
// 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.
// Patterns and replacements for URL and email tags..
$patterns = array();
$replacements = array();
if ( ($user_posts >= $needposts || $userdata['user_id'] == $poster_id) && $userdata['user_id'] != -1)
{
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['post'];
}
else
{
$text1 = str_replace($tneedposts, $needposts, $text1);
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['hpost'];
}
$text1 = preg_replace($patterns, $replacements, $text1);
$text1 = substr($text1, 1);
return $text1 . $text2;
}
function post_hide_in_quote($text)
{
$text = preg_replace("#\[post=(.*?)\](.*?)\[\/post\]#si","--- 你不能引言隱藏的文章內容 ---", $text);
return $text;
}
//
//Post Topics Hide Mod - End
//
#
#-----[ 尋找 ]------------------------------------------
#
// Remove our padding from the string..
return substr($text, 1);;
#
#-----[ 前面加上 ]------------------------------------------
#
//[post=]message[/post]
$text = preg_replace("#\[post=(.*?)\](.*?)\[/post\]#si","[post=\\\1:$uid]\\\2[/post:$uid]", $text);
#
#-----[ 開啟 ]------------------------------------------
#
include/topic_review.php
#
#-----[ 尋找 ]------------------------------------------
#
if ( $bbcode_uid != "" )
{
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
#
#-----[ 前面加上 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$setpost = false;
$setpost = bbencode_post_pass_first($row['post_text'],$bbcode_uid,0);
//
//Post Topics Hide Mod - End
//
#
#-----[ 後面加上 ]------------------------------------------
#
if($setpost == true)
$message = bbencode_post_pass($message,$bbcode_uid,$poster_id);
#
#-----[ 開啟 ]------------------------------------------
#
language/.../lang_main.php
#
#-----[ 尋找 ]------------------------------------------
#
$lang['bbcode_f_help'] = '字型大小: [size=x-small]small text[/size]';
#
#-----[ 後面加上 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$lang['bbcode_post_help'] = "隱藏內容:[post=發表數]隱藏文字內容[/post]";
//
//Post Topics Hide Mod - End
//
//註:如果有使用熱鍵的話可以自己加上去\r
#
#-----[ 開啟 ]------------------------------------------
#
posting.php
#
#-----[ 尋找 ]------------------------------------------
#
if( !$html_on )
{
if( $user_sig != '' || !$userdata['user_allowhtml'] )
{
$user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', '<\2>', $user_sig);
}
}
#
#-----[ 後面加上 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$setpost = FALSE;
$setpost = bbencode_post_pass_first($preview_message,$bbcode_uid,0);
//
//Post Topics Hide Mod - End
//
#
#-----[ 尋找 ]------------------------------------------
#
$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']);
#
#-----[ 尋找 ]------------------------------------------
#
$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']);
#
#-----[ 尋找 ]------------------------------------------
#
if ( !preg_match('/^Re:/', $subject) && strlen($subject) > 0 )
{
$subject = 'Re: ' . $subject;
}
#
#-----[ 後面加上 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$setpost = false;
$setpost = bbencode_post_pass_first($post_info['post_text'],$post_info['bbcode_uid'],0);
if($setpost == TRUE)
$needposts = bbencode_post_pass_first($post_info['post_text'],$post_info['bbcode_uid'],1);
if((($userdata['user_posts']-$userdata['user_reply']) < $needposts || $post_data['poster_id'] == $userdata['user_id']) && $userdata['user_id'] != -1)
$message = post_hide_in_quote($message);
//
//Post Topics Hide Mod - End
//
//註:($userdata['user_posts']-$userdata['user_reply'])代表以發表主題數隱藏
// 總發表數的話改為$userdata['user_posts']即可\r
#
#-----[ 開啟 ]------------------------------------------
#
viertopic.php
#
#-----[ 尋找 ]------------------------------------------
#
if ( $board_config['allow_bbcode'] )
{
#
#-----[ 後面加上 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$setpost = FALSE;
$setpost = bbencode_post_pass_first($postrow[$i]['post_text'],$bbcode_uid,0);
$setpost2 = FALSE;
$setpost2 = bbencode_post_pass_first($user_sig,$user_sig_bbcode_uid,0);
//
//Post Topics Hide Mod - End
//
#
#-----[ 尋找 ]------------------------------------------
#
$user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $user_sig);
#
#-----[ 後面加上 ]------------------------------------------
#
if($setpost2 == TRUE)
$user_sig = bbencode_post_pass($user_sig,$user_sig_bbcode_uid,$poster_id);
#
#-----[ 尋找 ]------------------------------------------
#
$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);
#
#-----[ 隱藏附加檔案的話: ]------------------------------------------
#-----[ 尋找 ]------------------------------------------
#
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']);
#
#-----[ 開啟 ]------------------------------------------
#
search.php
#
#-----[ 尋找 ]------------------------------------------
#
//
// If the board has HTML off but the post has HTML
// on then we process it, else leave it alone
//
if ( $return_chars != -1 )
#
#-----[ 改成 ]------------------------------------------
#
//
// If the board has HTML off but the post has HTML
// on then we process it, else leave it alone
//
if ( $return_chars == -1 )
#
#-----[ 尋找 ]------------------------------------------
#
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
#
#-----[ 前面加上 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$setpost = FALSE;
$setpost = bbencode_post_pass_first($message,$bbcode_uid,0);
//
//Post Topics Hide Mod - End
//
#
#-----[ 後面加上 ]------------------------------------------
#
if($setpost == TRUE)
$message = bbencode_post_pass($message,$bbcode_uid,$poster_id);
#
#-----[ 開啟 ]------------------------------------------
#
templates/你的風格/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 -->
#
#-----[ 有安裝新聞快報的話: ]------------------------------------------
#-----[ 開啟 ]------------------------------------------
#
includes/news.php
#
#-----[ 尋找 ]------------------------------------------
#
$message = str_replace("
", "
<br />
", $message);
#
#-----[ 前面加上 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$setpost = false;
$setpost = bbencode_post_pass_first($news[$i]['post_text'],$bbcode_uid,0);
//
//Post Topics Hide Mod - End
//
#
#-----[ 後面加上 ]------------------------------------------
#
if($setpost == true)
$message = bbencode_post_pass($message,$bbcode_uid,$poster_id);
#
#-----[ 有安裝友善列印的話: ]------------------------------------------
#-----[ 開啟 ]------------------------------------------
#
printview.php
#
#-----[ 尋找 ]------------------------------------------
#
for($i = 0; $i < $total_posts; $i++)
{
#
#-----[ 後面加上 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$setpost = false;
$setpost = bbencode_post_pass_first($postrow[$i]['post_text'],$postrow[$i]['bbcode_uid'],0);
//
//Post Topics Hide Mod - End
//
#
#-----[ 尋找 ]------------------------------------------
#
$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
#
#-----[ 尋找 ]------------------------------------------
#
for($i = 0; $i < $total_posts; $i++)
{
#
#-----[ 後面加上 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$setpost = false;
$setpost = bbencode_post_pass_first($postrow[$i]['post_text'],$postrow[$i]['bbcode_uid'],0);
//
//Post Topics Hide Mod - End
//
#
#-----[ 尋找 ]------------------------------------------
#
$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);
#
#-----[ 有安裝ezPortal mod的話: ]------------------------------------------
#-----[ 開啟 ]------------------------------------------
#
fetchposts.php
#
#-----[ 尋找 ]------------------------------------------
#
//
// do a little magic
// note: part of this comes from mds' news script and some additional magics from Smartor
//
#
#-----[ 前面加上 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$setpost = false;
$setpost = bbencode_post_pass_first($posts[$i]['post_text'],$posts[$i]['bbcode_uid'],0);
//
//Post Topics Hide Mod - End
//
#
#-----[ 尋找 ]------------------------------------------
#
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;
}
#
#-----[ 尋找 ]------------------------------------------
#
$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']);
#
#-----[ 有安裝主題預覽的話 ]------------------------------------------
#-----[ 開啟 ]------------------------------------------
#
viewforum.php
#
#-----[ 尋找 ]------------------------------------------
#
$topic_content = strip_tags($topic_content);
#
#-----[ 後面加上 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$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'] - $userdata['user_reply']) >= $needposts || $userdata['user_id'] == $topic_rowset[$i]['poster_id']) && $userdata['user_id'] != -1)
$topic_content = $postcontent1 . $lang['PostHideShowStart'] . $postcontent . $lang['PostHideShowEnd'] . $postcontent2;
else
$topic_content = $postcontent1 . $lang['PostHide'] . $postcontent2;
}
//
//Post Topics Hide Mod - End
//
//註:($userdata['user_posts']-$userdata['user_reply'])代表以發表主題數隱藏
// 總發表數的話改為$userdata['user_posts']即可\r
#
#-----[ 開啟 ]------------------------------------------
#
language/.../lang_main.php
#
#-----[ 尋找 ]------------------------------------------
#
//
//Post Topics Hide Mod - End
//
#
#-----[ 前面加上 ]------------------------------------------
#
$lang['PostHideShowStart'] = "***===以下為發表數隱藏文章內容===***
";
$lang['PostHideShowEnd'] = "
***===以上為發表數隱藏文章內容===***";
$lang['PostHide'] = "***===內文隱藏===***
神秘內容:
你必須達到規定的發表數才能觀看
***===內文隱藏===***";
#
#-----[ 儲存並關閉所有檔案 ]------------------------------------------
#
# EoM
代碼: 選擇全部
#################################################################
## Mod Title: 發表數隱藏文章(Post Topics Hide Mod)
## Mod Version: v1.2 => v1.3
## Author: emn178 - http://emn178.idv.st
##
## Description: 修正內容:bbcode.php,posting.php,viewforum部分修正了訪客部分的隱藏
## bbcode.php部分新增可以設定最大最小的文章需求數\r
##
## Installation Level: 易
## Installation Time: 3 Minutes
## Files To Edit: 1
## include/bbcode.php
##
## Included Files: N/A
#################################################################
#
#-----[ 開啟 ]------------------------------------------
#
include/bbcode.php
#
#-----[ 尋找 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
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'];
//註:如果要使用總發表數為條件或者未安裝區分主題與回覆Mod的話\r
//上面這行改成$user_posts = $userdata['user_posts'];
$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;
}
function post_hide_in_quote($text)
{
$text = preg_replace("#\[post=(.*?)\](.*?)\[\/post\]#si","--- 你不能引言隱藏的文章內容 ---", $text);
return $text;
}
//
//Post Topics Hide Mod - End
//
#
#-----[ 改成 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
function bbencode_post_pass_first($text,$uid,$x)
{
$needposts = preg_replace("#(.*?)\[post=(.*?):$uid\](.*?)\[/post:$uid\](.*?)#si","\\\2 ", $text);
$poststropsn = strpos($needposts, " ");
$needposts = substr($needposts,0,$poststropsn);
$tneedposts = $needposts;
if($needposts > 1000)
$needposts = 1000;
else if($needposts < 5 || $needposts/1 != $needposts)
$needposts = 5;
//註:> 1000和= 1000的1000是最大值, < 5和 = 5是最小值,改成你要的數值\r
$posttext1 = "[post=" . $tneedposts . ":$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'];
//註:如果要使用總發表數為條件或者未安裝區分主題與回覆Mod的話\r
//上面這行改成$user_posts = $userdata['user_posts'];
$needposts = preg_replace("#(.*?)\[post=(.*?):$uid\](.*?)\[/post:$uid\](.*?)#si","\\\2 ", $text);
$poststropsn = strpos($needposts, " ");
$needposts = substr($needposts,0,$poststropsn);
$tneedposts = $needposts;
if($needposts > 1000)
$needposts = 1000;
else if($needposts < 5 || $needposts/1 != $needposts)
$needposts = 5;
//註:> 1000和= 1000的1000是最大值, < 5和 = 5是最小值,改成你要的數值\r
// 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) && $userdata['user_id'] != -1)
{
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['post'];
}
else
{
$text = str_replace($tneedposts, $needposts, $text);
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['hpost'];
}
$text = preg_replace($patterns, $replacements, $text);
$text = substr($text, 1);
return $text;
}
function post_hide_in_quote($text)
{
$text = preg_replace("#\[post=(.*?)\](.*?)\[\/post\]#si","--- 你不能引言隱藏的文章內容 ---", $text);
return $text;
}
//
//Post Topics Hide Mod - End
//
#
#-----[ 尋找 ]------------------------------------------
#
//[post=]message[/post]
$text = preg_replace("#\[post=([0-9]?[0-9]?[0-9])\](.*?)\[/post\]#si","[post=\\\1:$uid]\\\2[/post:$uid]", $text);
#
#-----[ 改成 ]------------------------------------------
#
//[post=]message[/post]
$text = preg_replace("#\[post=(.*?)\](.*?)\[/post\]#si","[post=\\\1:$uid]\\\2[/post:$uid]", $text);
#
#-----[ 開啟 ]------------------------------------------
#
posting.php
#
#-----[ 尋找 ]------------------------------------------
#
if(($userdata['user_posts']-$userdata['user_reply']) < $needposts || $post_data['poster_id'] == $userdata['user_id'])
$message = post_hide_in_quote($message);
#
#-----[ 改成 ]------------------------------------------
#
if((($userdata['user_posts']-$userdata['user_reply']) < $needposts || $post_data['poster_id'] == $userdata['user_id']) && $userdata['user_id'] != -1)
$message = post_hide_in_quote($message);
#
#-----[ 有安裝主題預覽的話 ]------------------------------------------
#-----[ 開啟 ]------------------------------------------
#
viewforum.php
#
#-----[ 尋找 ]------------------------------------------
#
if(($userdata['user_posts'] - $userdata['user_reply']) >= $needposts || $userdata['user_id'] == $topic_rowset[$i]['poster_id'])
$topic_content = $postcontent1 . $lang['PostHideShowStart'] . $postcontent . $lang['PostHideShowEnd'] . $postcontent2;
#
#-----[ 改成 ]------------------------------------------
#
if((($userdata['user_posts'] - $userdata['user_reply']) >= $needposts || $userdata['user_id'] == $topic_rowset[$i]['poster_id']) && $userdata['user_id'] != -1)
$topic_content = $postcontent1 . $lang['PostHideShowStart'] . $postcontent . $lang['PostHideShowEnd'] . $postcontent2;
#
#-----[ 儲存並關閉所有檔案 ]------------------------------------------
#
# EoM
代碼: 選擇全部
#################################################################
## Mod Title: 發表數隱藏文章(Post Topics Hide Mod)
## Mod Version: v1.3 => v1.4
## Author: emn178 - http://emn178.idv.st
##
## Description: 修正內容:viewtopic.php部分修正了簽名檔顯示問題
##
##
## Installation Level: 易
## Installation Time: 1 Minutes
## Files To Edit: 1
## viewtopic.php
##
## Included Files: N/A
#################################################################
#
#-----[ 開啟 ]------------------------------------------
#
viewtopic.php
#
#-----[ 尋找 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$setpost = FALSE;
$setpost = bbencode_post_pass_first($postrow[$i]['post_text'],$bbcode_uid,0);
//
//Post Topics Hide Mod - End
//
#
#-----[ 改成 ]------------------------------------------
#
//
//Post Topics Hide Mod - Start
//
$setpost = FALSE;
$setpost = bbencode_post_pass_first($postrow[$i]['post_text'],$bbcode_uid,0);
$setpost2 = FALSE;
$setpost2 = bbencode_post_pass_first($user_sig,$user_sig_bbcode_uid,0);
//
//Post Topics Hide Mod - End
//
#
#-----[ 尋找 ]------------------------------------------
#
if($setpost == TRUE)
$user_sig = bbencode_post_pass($user_sig,$bbcode_uid,$poster_id);
#
#-----[ 改成 ]------------------------------------------
#
if($setpost2 == TRUE)
$user_sig = bbencode_post_pass($user_sig,$user_sig_bbcode_uid,$poster_id);
#
#-----[ 儲存並關閉所有檔案 ]------------------------------------------
#
# EoM
代碼: 選擇全部
#################################################################
## Mod Title: 發表數隱藏文章(Post Topics Hide Mod)
## Mod Version: v1.4 => v1.5
## Author: emn178 - http://emn178.idv.st
##
## Description: 修正內容:bbcode.php部分修正了多重隱藏時,達到第一個隱藏條件會全部顯示的問題
##
##
## Installation Level: 易
## Installation Time: 1 Minutes
## Files To Edit: 1
## bbcode.php
##
## Included Files: N/A
#################################################################
#
#-----[ 開啟 ]------------------------------------------
#
bbcode.php
#
#-----[ 尋找 ]------------------------------------------
#
function bbencode_post_pass($text,$uid,$poster_id)
{
global $bbcode_tpl,$userdata;
$user_posts = $userdata['user_posts'] - $userdata['user_reply'];
//註:如果要使用總發表數為條件或者未安裝區分主題與回覆Mod的話\r
//上面這行改成$user_posts = $userdata['user_posts'];
$needposts = preg_replace("#(.*?)\[post=(.*?):$uid\](.*?)\[/post:$uid\](.*?)#si","\\\2 ", $text);
$poststropsn = strpos($needposts, " ");
$needposts = substr($needposts,0,$poststropsn);
$tneedposts = $needposts;
if($needposts > 1000)
$needposts = 1000;
else if($needposts < 5 || $needposts/1 != $needposts)
$needposts = 5;
//註:> 1000和= 1000的1000是最大值, < 5和 = 5是最小值,改成你要的數值\r
// 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) && $userdata['user_id'] != -1)
{
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['post'];
}
else
{
$text = str_replace($tneedposts, $needposts, $text);
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['hpost'];
}
$text = preg_replace($patterns, $replacements, $text);
$text = substr($text, 1);
return $text;
}
#
#-----[ 改成 ]------------------------------------------
#
function bbencode_post_pass($text,$uid,$poster_id)
{
global $bbcode_tpl,$userdata;
$user_posts = $userdata['user_posts'] - $userdata['user_reply'];
//註:如果要使用總發表數為條件或者未安裝區分主題與回覆Mod的話\r
//上面這行改成$user_posts = $userdata['user_posts'];
$needposts = preg_replace("#(.*?)\[post=(.*?):$uid\](.*?)\[/post:$uid\](.*?)#si","\\\2 ", $text);
if(!$needposts)
return $text;
$poststropsn = strpos($needposts, " ");
$needposts = substr($needposts,0,$poststropsn);
$posttext = "[/post:$uid]";
$poststrops = strpos($text, $posttext);
$text1 = substr($text,0,$poststrops+18);
$text2 = substr($text,$poststrops+19,strlen($text) - ($poststrops+19));
$text2 = bbencode_post_pass($text2,$uid,$poster_id);
$tneedposts = $needposts;
if($needposts > 1000)
$needposts = 1000;
else if($needposts < 5 || $needposts/1 != $needposts)
$needposts = 5;
//註:> 1000和= 1000的1000是最大值, < 5和 = 5是最小值,改成你要的數值\r
// 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) && $userdata['user_id'] != -1)
{
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['post'];
}
else
{
$text1 = str_replace($tneedposts, $needposts, $text1);
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['hpost'];
}
$text1 = preg_replace($patterns, $replacements, $text1);
$text1 = substr($text1, 1);
return $text1 . $text2;
}
#
#-----[ 儲存並關閉所有檔案 ]------------------------------------------
#
# EoM
代碼: 選擇全部
#################################################################
## Mod Title: 發表數隱藏文章(Post Topics Hide Mod)
## Mod Version: v1.5 => v1.6
## Author: emn178 - http://emn178.idv.st
##
## Description: 修正內容:bbcode.php部分修正了一些bug
##
##
## Installation Level: 易
## Installation Time: 1 Minutes
## Files To Edit: 1
## bbcode.php
##
## Included Files: N/A
#################################################################
#
#-----[ 開啟 ]------------------------------------------
#
bbcode.php
#
#-----[ 尋找 ]------------------------------------------
#
function bbencode_post_pass($text,$uid,$poster_id)
{
global $bbcode_tpl,$userdata;
$user_posts = $userdata['user_posts'] - $userdata['user_reply'];
//註:如果要使用總發表數為條件或者未安裝區分主題與回覆Mod的話\r
//上面這行改成$user_posts = $userdata['user_posts'];
$needposts = preg_replace("#(.*?)\[post=(.*?):$uid\](.*?)\[/post:$uid\](.*?)#si","\\\2 ", $text);
if(!$needposts)
return $text;
$poststropsn = strpos($needposts, " ");
$needposts = substr($needposts,0,$poststropsn);
$posttext = "[/post:$uid]";
$poststrops = strpos($text, $posttext);
$text1 = substr($text,0,$poststrops+18);
$text2 = substr($text,$poststrops+19,strlen($text) - ($poststrops+19));
$text2 = bbencode_post_pass($text2,$uid,$poster_id);
$tneedposts = $needposts;
if($needposts > 1000)
$needposts = 1000;
else if($needposts < 5 || $needposts/1 != $needposts)
$needposts = 5;
//註:> 1000和= 1000的1000是最大值, < 5和 = 5是最小值,改成你要的數值\r
// 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) && $userdata['user_id'] != -1)
{
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['post'];
}
else
{
$text1 = str_replace($tneedposts, $needposts, $text1);
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['hpost'];
}
$text1 = preg_replace($patterns, $replacements, $text1);
$text1 = substr($text1, 1);
return $text1 . $text2;
}
#
#-----[ 改成 ]------------------------------------------
#
function bbencode_post_pass($text,$uid,$poster_id)
{
global $bbcode_tpl,$userdata;
$user_posts = $userdata['user_posts'] - $userdata['user_reply'];
//註:如果要使用總發表數為條件或者未安裝區分主題與回覆Mod的話\r
//上面這行改成$user_posts = $userdata['user_posts'];
$needposts = preg_replace("#(.*?)\[post=(.*?):$uid\](.*?)\[/post:$uid\](.*?)#si","\\\2 ", $text);
if(!$needposts)
return $text;
$text = " " . $text;
$poststropsn = strpos($needposts, " ");
$needposts = substr($needposts,0,$poststropsn);
$posttext = "[/post:$uid]";
$poststrops = strpos($text, $posttext);
$text1 = substr($text,0,$poststrops+18);
$text2 = substr($text,$poststrops+18,strlen($text) - ($poststrops+18));
$text2 = bbencode_post_pass($text2,$uid,$poster_id);
$tneedposts = $needposts;
if($needposts > 1000)
$needposts = 1000;
else if($needposts < 5 || $needposts/1 != $needposts)
$needposts = 5;
//註:> 1000和= 1000的1000是最大值, < 5和 = 5是最小值,改成你要的數值\r
// 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.
// Patterns and replacements for URL and email tags..
$patterns = array();
$replacements = array();
if ( ($user_posts >= $needposts || $userdata['user_id'] == $poster_id) && $userdata['user_id'] != -1)
{
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['post'];
}
else
{
$text1 = str_replace($tneedposts, $needposts, $text1);
$patterns[0] = "#\[post=(.*?):$uid\](.*?)\[/post:$uid\]#si";
$replacements[0] = $bbcode_tpl['hpost'];
}
$text1 = preg_replace($patterns, $replacements, $text1);
$text1 = substr($text1, 1);
return $text1 . $text2;
}
#
#-----[ 儲存並關閉所有檔案 ]------------------------------------------
#
# EoM
而這裡又不能用回覆的方式取消使用BBCode
所以可以到我的論壇上看看
有問題可以到\r
http://phpbb-tw.net/phpbb/viewtopic.php?t=23813
或我的論壇提出討論
