[分享]hide for phpbb plus..1.53

phpBB Plus Support
本區是討論關於 phpBB 2 plus 使用上的問題討論!
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

主題已鎖定
bibo8045
星球公民
星球公民
文章: 83
註冊時間: 2005-03-06 18:34

[分享]hide for phpbb plus..1.53

文章 bibo8045 »

小弟找好久..終於給翻到這篇文章~
原文裡頭有些跟1.53不太一樣..小弟有做些比對並修改~希望對大家有幫助!
簡單說這個就是隱藏一段話,其他人要看要做回應!至於應用範圍就各自發揮嚕
倉促簡短說明..請大家多多包含或多提些意見

原始文章: http://www.phpbb2.de/ftopic34730.html

代碼: 選擇全部

1 - 打開 posting.php  

找到  

if( $attach_sig && $user_sig != '' && $userdata['user_sig_bbcode_uid'] ) 
{ 
        $user_sig = bbencode_second_pass($user_sig, $userdata['user_sig_bbcode_uid']); 
} 

if( $bbcode_on ) 
{ 
        $preview_message = bbencode_second_pass($preview_message, $bbcode_uid); 
} 
  
換成
 
$valid = FALSE; 
if( $userdata['session_logged_in'] ) { 
$sql = "SELECT p.poster_id, p.topic_id 
FROM " . POSTS_TABLE . " p 
WHERE p.topic_id = $topic_id 
AND p.poster_id = " . $userdata['user_id']; 
$resultat = $db->sql_query($sql); 
$valid = $db->sql_numrows($resultat) ? TRUE : FALSE;} 
if (!($valid)) $valid = $is_auth['auth_mod'] ? TRUE : FALSE; 


if( $attach_sig && $user_sig != '' && $userdata['user_sig_bbcode_uid'] ) 
{ 
        $user_sig = bbencode_second_pass($user_sig, $userdata['user_sig_bbcode_uid']); 
        $user_sig = bbencode_third_pass($user_sig, $userdata['user_sig_bbcode_uid'], $valid); 
} 

if( $bbcode_on ) 
{ 
        $preview_message = bbencode_second_pass($preview_message, $bbcode_uid); 
        $preview_message = bbencode_third_pass($preview_message, $bbcode_uid, $valid); 
} 
 
找到  
 
if ( !preg_match('/^Re:/', $subject) && strlen($subject) > 0 ) 
{ 
        $subject = 'Re: ' . $subject; 
} 
   
在後面加入 

$valid=FALSE; 
if( $userdata['session_logged_in'] ) { 
$sql = "SELECT p.poster_id, p.topic_id 
FROM " . POSTS_TABLE . " p 
WHERE p.topic_id = $topic_id 
AND p.poster_id = " . $userdata['user_id']; 
$resultat = $db->sql_query($sql); 
if ($db->sql_numrows($resultat)) $valid=TRUE; 
} 
if (($valid == FALSE) && ($is_auth['auth_mod'] == FALSE)) $message=hide_in_quote($message); 


2 - 打開 viewtopic.php  

找到  

// 
// Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed 
// then get it's value, find the number of topics with dates newer than it (to properly 
// handle pagination) and alter the main query 
// 
  
後面加入  

$valid = FALSE; 
if( $userdata['session_logged_in'] ) { 
$sql = "SELECT p.poster_id, p.topic_id 
FROM " . POSTS_TABLE . " p 
WHERE p.topic_id = $topic_id 
AND p.poster_id = " . $userdata['user_id']; 
$resultat = $db->sql_query($sql); 
$valid = $db->sql_numrows($resultat) ? TRUE : FALSE;} 
if (!($valid)) $valid = $is_auth['auth_mod'] ? TRUE : FALSE; 

  
找到  
if ($user_sig != '' && $user_sig_bbcode_uid != '')
	{
		$user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig);
	}

	if ($bbcode_uid != '')
	{
		$message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $message);
  
置換成  
	if ($user_sig != '' && $user_sig_bbcode_uid != '')
	{
		$user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig);
		$user_sig = bbencode_third_pass($user_sig, $user_sig_bbcode_uid, $valid);
	}

	if ($bbcode_uid != '')
	{
		$message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $message);
		$message = bbencode_third_pass($message, $bbcode_uid, $valid);
	}

3 - 打開 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 ) 
  
找到  

if ( $bbcode_uid != '' ) 
{ 
        $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); 
} 
  
置換成 

if ( $bbcode_uid != '' ) 
{ 
        $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, FALSE); 
} 
  
4 - 打開 /includes/topic_review.php  
 
Find  
 
        // 
        // Okay, let's do the loop, yeah come on baby let's do the loop 
        // and it goes like this ... 
        // 
        if ( $row = $db->sql_fetchrow($result) ) 
        { 
 
在後面增加  

$valid = FALSE; 
if( $userdata['session_logged_in'] ) { 
$sql = "SELECT p.poster_id, p.topic_id 
FROM " . POSTS_TABLE . " p 
WHERE p.topic_id = $topic_id 
AND p.poster_id = " . $userdata['user_id']; 
$resultat = $db->sql_query($sql); 
$valid = $db->sql_numrows($resultat) ? TRUE : FALSE;} 
if (!($valid)) $valid = $is_auth['auth_mod'] ? TRUE : FALSE; 


找到 

if ( $bbcode_uid != "" ) 
{ 
        $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); 
} 
  
置換成  

if ( $bbcode_uid != "" ) 
{ 
        $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); 
} 
  

5 - 打開 /includes/bbcode.php  
 
找到  

$bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']);  


在後面增加  

$bbcode_tpl['show'] = str_replace('{HTEXTE}', '\\1', $bbcode_tpl['show']); 
  
找到  
 
/** 
 * 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. 
 */ 
  
在前面增加  

function hide_in_quote($text) 
{ 
        $text = preg_replace("#\[hide\](.*?)\[\/hide\]#si","--- phpBB : The Protected Message is not copied in this quote ---", $text); 
        return $text; 
} 

function bbencode_third_pass($text, $uid, $deprotect) 
{ 
        global $bbcode_tpl; 

        // 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; 

        // First: If there isn't a "[" and a "]" in the message, don't bother. 
        if (! (strpos($text, "[") && strpos($text, "]")) ) 
        { 
                // Remove padding, return. 
                $text = substr($text, 1); 
                return $text; 
        } 
        // Patterns and replacements for URL and email tags.. 
        $patterns = array(); 
        $replacements = array(); 
  
        if ( $deprotect ) { 
        $patterns[0] = "#\[hide:$uid\](.*?)\[/hide:$uid\]#si"; 
        $replacements[0] = $bbcode_tpl['show']; 
        } 
        else 
        { 
        $patterns[0] = "#\[hide:$uid\](.*?)\[/hide:$uid\]#si"; 
        $replacements[0] = $bbcode_tpl['hide']; 
        } 

        $text = preg_replace($patterns, $replacements, $text); 
  
        // Remove our padding from the string.. 
        $text = substr($text, 1); 

        return $text; 
} 
  
 
找到  

// [img]image_url_here[/img] code.. 
$text = preg_replace("#\[img\](([a-z]+?)://([^ \"\n\r]+?))\[/img\]#si", "[img:$uid]\\1[/img:$uid]", $text);  

在後面增加  

//[hide]message[/hide] 
$text = preg_replace("#\[hide\](.*?)\[\/hide\]#si","[hide:$uid]\\1[/hide:$uid]", $text);  

###############################################
6 - 打開 Templates/{Used template}/bbcode.tpl  
############################################### 
直接加在最前面  
############################################### 
<!-- BEGIN show --> 
</span> 
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1"> 
<tr> 
          <td><span class="genmed"><b>Protected Message:</b></span></td> 
        </tr> 
        <tr> 
          <td class="quote"> 
                {HTEXTE} 
                </td> 
        </tr> 
</table> 
<span class="postbody"> 
<!-- END show --> 

<!-- BEGIN hide --> 
</span> 
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1"> 
<tr> 
          <td><span class="genmed"><b>Protected Message:</b></span></td> 
        </tr> 
        <tr> 
          <td class="quote"> 
                <center>--- If you are a *registered user* : you need to post in this topic to see the message ---</center> 
                </td> 
        </tr> 
</table> 
<span class="postbody"> 
<!-- END hide --> 

上面這一段我保留原文..請自行翻譯自己覺得適合的中文說詞
==================== 
打開 printview.php 
==================== 
找到 
  
// 
// Loop through the posts 
// 

在後面增加 
  
$valid = FALSE; 
if( $userdata['session_logged_in'] ) { 
$sql = "SELECT p.poster_id, p.topic_id 
FROM " . POSTS_TABLE . " p 
WHERE p.topic_id = $topic_id 
AND p.poster_id = " . $userdata['user_id']; 
$resultat = $db->sql_query($sql); 
$valid = $db->sql_numrows($resultat) ? TRUE : FALSE;} 


找到

	if ($bbcode_uid != '')
	{
		$message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $message);

add after 
Code: 

$message = bbencode_third_pass($message, $bbcode_uid, $valid); 
  

==================== 
打開 export.php 
==================== 
找到 
Code: 
   // 
   // Parse message and/or sig for BBCode if reqd 
   // 

在後面增加 

$valid = FALSE; 
if( $userdata['session_logged_in'] ) { 
$sql = "SELECT p.poster_id, p.topic_id 
FROM " . POSTS_TABLE . " p 
WHERE p.topic_id = $topic_id 
AND p.poster_id = " . $userdata['user_id']; 
$resultat = $db->sql_query($sql); 
$valid = $db->sql_numrows($resultat) ? TRUE : FALSE;} 


找到 

	if ($user_sig != '' && $user_sig_bbcode_uid != '')
	{
		$user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig);

在後面增加 

$user_sig = bbencode_third_pass($user_sig, $user_sig_bbcode_uid, $valid); 


找到 

	if ($bbcode_uid != '')
	{
		$message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $message);

在後面增加 
Code: 

$message = bbencode_third_pass($message, $bbcode_uid, $valid); 


==================== 
打開 include/news.php 
==================== 
找到 
  
  function NewsModule( $root_path ) 
  { 
    global $CFG, $db, $phpEx, $template, $board_config; 

置換成 

  function NewsModule( $root_path ) 
  { 
    global $CFG, $db, $phpEx, $template, $board_config, $userdata; 


找到 

    $this->root_path  = 'http://' . $board_config['server_name'] . $server_port . $board_config['script_path']; 
    $this->phpEx      = $phpEx; 
    $this->template   = &$template; 
    $this->config     = &$board_config; 

在後面增加 

    $this->userdata     = &$userdata; 
    $this->db     = &$db; 


找到 
  
 // Trim the post body if needed. 
        if( $show_abstract && $this->config['news_item_trim'] > 0 ) 
        { 
          $article['post_abstract'] = $this->trimText( $article['post_text'], $this->config['news_item_trim'], $trimmed ); 
          $article['post_abstract'] = $this->parseMessage( $article['post_abstract'] . ' ... ', $article['bbcode_uid'] ); 
        } 

        $article['post_text'] = $this->parseMessage( $article['post_text'], $article['bbcode_uid'] ); 

置換成 

// Trim the post body if needed. 
        if( $show_abstract && $this->config['news_item_trim'] > 0 ) 
        { 
          $article['post_abstract'] = $this->trimText( $article['post_text'], $this->config['news_item_trim'], $trimmed ); 
          $article['post_abstract'] = $this->parseMessage( $article['post_abstract'] . ' ... ', $article['bbcode_uid'], $article['topic_id'] ); 
        } 

        $article['post_text'] = $this->parseMessage( $article['post_text'], $article['bbcode_uid'], $article['topic_id'] ); 


找到 
  
$comment['post_text'] = $this->parseMessage( $comment['post_text'], $comment['bbcode_uid'] ); 

置換成 
  
$comment['post_text'] = $this->parseMessage( $comment['post_text'], $comment['bbcode_uid'], $article['topic_id'] ); 


找到 

  function decodeBBText( $text, $bbcode_uid ) 

置換成 
  function decodeBBText( $text, $bbcode_uid, $topic_id ) 


找到 

    // 
    // Parse message and/or sig for BBCode if reqd 
    // 

在後面增加
  
$valid = FALSE; 
if( $this->userdata['session_logged_in'] ) { 
$sql = "SELECT p.poster_id, p.topic_id 
FROM phpbb_posts p 
WHERE p.topic_id = $topic_id 
AND p.poster_id =  " . $this->userdata['user_id']; 
$resultat = $this->db->sql_query($sql); 
$valid = $this->db->sql_numrows($resultat) ? TRUE : FALSE;} 


找到 
    if ( $bbcode_uid != '' ) 
    { 
      $text = ( $this->config['allow_bbcode'] ) ? bbencode_second_pass($text, $bbcode_uid) : preg_replace('/\: [0-9a-z\:]+\]/si', ']', $text); 

在後面增加 
   $text = bbencode_third_pass($text, $bbcode_uid, $valid); 


找到 
Code: 

  function parseMessage( $text, $bbcode_uid ) 
  { 
    $text  = $this->decodeBBText( $text, $bbcode_uid ); 

置換成 
Code: 

  function parseMessage( $text, $bbcode_uid, $topic_id ) 
  { 
    $text  = $this->decodeBBText( $text, $bbcode_uid, $topic_id ); 


======================= 
打開 the bbcode_box/add_bbcode.js 
======================= 
找到
b_help = "粗體: [b]text[/b]"; 

add after 
Code: 

h_help = "隱藏: [hide]text[/hide]"; 

找到
var Quote = 0; 

之後加上
var Hide = 0; 


找到
function BBCmarqu() { 
   if ((clientVer >= 4) && is_ie && is_win) { 
      theSelection = document.selection.createRange().text; 
      if (theSelection != '') { 
      document.selection.createRange().text = "[marq=up]" + theSelection + "[/marq]"; 
      document.post.message.focus(); 
      return; 
      } 
   } 
   if (marqu == 0) { 
      ToAdd = "[marq=up]"; 
      document.post.marqu.src = "bbcode_box/images/marqu1.gif"; 
      marqu = 1; 
   } else { 
      ToAdd = "[/marq]"; 
      document.post.marqu.src = "bbcode_box/images/marqu.gif"; 
      marqu = 0; 
   } 
   PostWrite(ToAdd); 
} 

之後加上
function BBChide() { 
   if ((clientVer >= 4) && is_ie && is_win) { 
      theSelection = document.selection.createRange().text; 
      if (theSelection != '') { 
      document.selection.createRange().text = "[hide]" + theSelection + "[/hide]"; 
      document.post.message.focus(); 
      return; 
      } 
   } 
   if (Hide == 0) { 
      ToAdd = "[hide]"; 
      document.post.hide.src = "bbcode_box/images/hide1.gif"; 
      Hide = 1; 
   } else { 
      ToAdd = "[/hide]"; 
      document.post.hide.src = "bbcode_box/images/hide.gif"; 
      Hide = 0; 
   } 
   PostWrite(ToAdd); 
} 

========================== 
打開 templates file posting_body.tpl 
========================== 
找到 
<img border="0" src="bbcode_box/images/plain.gif" width="24" height="20" name="plain" type="image" onClick="BBCplain()" onMouseOver="helpline('plain')" style="border-style: outset; border-width: 1" alt="Remove BBcode">

之後加上
<img border="0" src="bbcode_box/images/hide.gif" width="24" height="20" name="hide" type="image" onClick="BBChide()" onMouseOver="helpline('h')" style="border-style: outset; border-width: 1" alt="隱藏文字"> 
還有兩個圖檔請下載後放到\bbcode_box\images裡面

圖檔
圖檔
頭像
b8303053
星球公民
星球公民
文章: 71
註冊時間: 2005-03-10 22:03
來自: 大鬍子藥房
聯繫:

文章 b8303053 »

圖檔看不到了... :roll:

可否補一下.謝謝
●架設主機作業系統:windows XP(自己電腦)
●快速架站程式:Appserv 2.4.7
●上網方式:SeedNet ADSL
● phpBB2plus 版本:1.5.3(utf8)
● 連結網址: http://pharmacy.mytw.net/
● 測試用帳號密碼:test/test
kenspc
星球公民
星球公民
文章: 69
註冊時間: 2006-11-12 20:31
聯繫:

文章 kenspc »

用我的吧

圖檔
圖檔
主題已鎖定

回到「phpBB 2 plus 綜合討論」