[外掛][修改]合併HideMode4和attach_mod_245並在使用HIDE時自動隱藏檔案

MODs Released by Other phpbb Sites
非官方認證通過之 MOD ,或許有安全性之疑慮,所有問題由原發表者回覆!

版主: 版主管理群

主題已鎖定
肥貓
星球普通子民
星球普通子民
文章: 8
註冊時間: 2007-06-28 11:17
來自: 高雄某地

[外掛][修改]合併HideMode4和attach_mod_245並在使用HIDE時自動隱藏檔案

文章 肥貓 »

首先要感謝 心靈捕手 以及 ~倉木麻衣~ 兩位大大的教學文章
才讓小弟我更進步~~ :-P :-P :-P

下次小弟發文時,會特別注意前輩們的版權~~~ :oops: :oops: :oops:

代碼: 選擇全部

############################################################## 
## 外掛名稱: 合併HideMode4和attach_mod_245自動隱藏附加檔案 
##
## 外掛作者: CAT < h5201141@yahoo.com.tw > http://sh31.no-ip.com/nkmu91me5
## 
## 外掛說明: 
##       合併HideMode4和attach_mod_245,
##       在文章使用[hide]時...自動隱藏附加檔案...回復之後才可下載
##       沒有使用[Hide]時...不隱藏附加檔案...
##                  
## 外掛版本: 1.0.0 
## 
## 安裝難度: Easy 
## 安裝時間: 10 Minutes 
## 編輯檔案: ./includes/bbcode.php 
##	     ./templates/subSilver/bbcode.tpl
##           ./attach_mod/displaying.php 
##           ./language/lang_chinese_traditional_taiwan/lang_main_attach.php 
##           ./templates/subSilver/viewtopic_attach_body.tpl 
##
##
##
## 附加檔案: X 
## 版權聲明: GNU General Public License v2
##           http://opensource.org/licenses/gpl-license.php  
############################################################## 
## 由於安全上的考量, 請檢查: http://phpbb-tw.net/phpbb/index.php 
## 是否有此外掛的最新版本. 
################################################################ 
## 作者備註: 
##           非常感謝 心靈捕手 以及 ~倉木麻衣~ 兩位大大的教學文章 ^^
##
##
##           [強烈建議]先安裝Attach_Mod_245以及HideMode之後
##           按照 ~倉木麻衣~ 大大以及 心靈捕手 大大的步驟修改完成!!
##
##           (幫 ~倉木麻衣~ 大大以及 心靈捕手 大大整理,以下會再寫一次)
##
##           1. ~倉木麻衣~大大的教學文章
##              http://phpbb-tw.net/phpbb/viewtopic.php?p=255061#255061
##           
##           2. 心靈捕手大大的教學文章
##              http://phpbb2.tw/phpbb/viewtopic.php?t=48705
##
##
##           注意,不是在語言檔裡面的中文字,儲存時請以您論壇的語系儲存!
##           
## 預先安裝
## 外掛作者: Attach_Mod_245  
##              (Acyd Burn < N/A > (Meik Sievertsen) http://www.opentools.de/)
##           HideMode 
##              (Philiweb < http://www.philiweb.fr.st/ > )
############################################################## 
## 外掛歷史: 
## 
##   2007-07-14 - 版本 1.0.0 
##      - 在phpbb 2.0.22中測試無誤 
## 
############################################################## 
## 新增外掛前, 請先備份相關檔案. 
##############################################################

以下是~倉木麻衣~大大的修改步驟:
以下是~倉木麻衣~大大的修改步驟:
以下是~倉木麻衣~大大的修改步驟:
# 
#--------[ OPEN ]---------------- 
# 
attach_mod/displaying.php 

# 
#--------[ FIND ]---------------- 
# 
代碼: 
   if (intval($switch_attachment) == 0 || (!($is_auth['auth_download'] && $is_auth['auth_view'])) || intval($attach_config['disable_mod']) || $attach_config['topic_icon'] == '') 


# 
#--------[ REPLACE WITH ]---------------- 
# 
代碼: 
   if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || $attach_config['topic_icon'] == '') 


# 
#--------[ FIND ]---------------- 
# 
代碼: 
      // Not included because this would mean template and language file changes (at this stage this is not a wise step. ;)) 

# 
#--------[ AFTER, ADD ]---------------- 
# 
代碼: 
display_attachments_notice(); 

# 
#--------[ FIND ]---------------- 
# 
代碼: 
?> 


# 
#--------[ BEFORE, ADD ]---------------- 
# 
代碼: 
function display_attachments_notice() 
{ 
   global $template, $lang; 

   init_display_template('body', '{postrow.ATTACHMENTS}'); 
   $template->assign_block_vars('postrow.attach', array()); 
   $template->assign_block_vars('postrow.attach.attach_notice', array( 
      NOTICE   =>   $lang['Attach_Notice'] 
   )); 
} 


# 
#--------[ OPEN ]---------------- 
# 
language/lang_chinese_traditional_taiwan/lang_main_attach.php 

# 
#--------[ FIND ]---------------- 
# 
代碼: 
?> 


# 
#--------[ BEFORE, ADD ]---------------- 
# 
代碼: 
$lang['Attach_Notice'] = '附加檔案: 您目前的權限無法檢視附加檔案'; 


# 
#--------[ OPEN ]---------------- 
# 
# 自行替換subSilver為你所使用的風格名稱目錄 
templates/subSilver/viewtopic_attach_body.tpl 

# 
#--------[ FIND ]---------------- 
# 
代碼: 
<!-- END attach --> 


# 
#--------[ BEFORE, ADD ]---------------- 
# 
代碼: 
<!-- BEGIN attach_notice --> 
   <br /><br /> 
      <div align="center"><hr width="95%" /></div> 
   <table width="95%" border="1" cellpadding="2" cellspacing="0" class="attachtable" align="center"> 
   <tr> 
      <td width="100%" class="attachheader" align="center"><b><span class="gen">{postrow.attach.attach_notice.NOTICE}</span></b></td> 
   </tr> 
   </table> 
<!-- END attach_notice --> 


# 
#--------[ SAVE/CLOSE ALL FILES ]---------------- 
# 
# EoM


以下是心靈捕手大大的修改步驟:
以下是心靈捕手大大的修改步驟:
以下是心靈捕手大大的修改步驟:
# 
#--------[ OPEN ]---------------- 
# 
attach_mod/displaying.php 

# 
#--------[ FIND ]---------------- 
# 
代碼: 

function display_post_attachments($post_id, $switch_attachment) 
{ 
   global $attach_config, $is_auth; 
 

# 
#--------[ REPLACE WITH ]---------------- 
# 
代碼: 

function display_post_attachments($post_id, $switch_attachment) 
{ 
   global $attach_config, $is_auth, $valid; 
 

# 
#--------[ FIND ]---------------- 
# 
代碼: 

   if ($is_auth['auth_download'] && $is_auth['auth_view']) 
 

# 
#--------[ REPLACE WITH ]---------------- 
# 
代碼: 

   if ($is_auth['auth_download'] && $is_auth['auth_view'] && $valid == TRUE) 
 

# 
#--------[ OPEN ]---------------- 
# 
language/lang_chinese_traditional_taiwan/lang_main_attach.php 

# 
#--------[ FIND ]---------------- 
# 
代碼: 
  
$lang['Attach_Notice'] = '附加檔案: 您目前的權限無法檢視附加檔案'; 
 

# 
#--------[ REPLACE WITH ]---------------- 
# 
代碼: 
  
$lang['Attach_Notice'] = '===== 附加檔案 =====<br />--- 如果您是 *註冊會員*, 那麼您必須登入和回覆文章後, 才可下載附加檔案 ---'; 

#-----[ OPEN ]----- 
# 
templates/subSilver/bbcode.tpl

# 
#-----[ FIND ]----- 
# ps. 有兩個 
代碼: 

Protected Message: 
 

# 
#-----[ REPLACE WITH ]----- 
# ps. 都取代 
代碼: 

隱藏訊息: 
 

# 
#-----[ FIND ]----- 
# 
代碼: 

--- If you are a *registered user* : you need to post in this topic to see the message --- 
 

# 
#-----[ REPLACE WITH ]----- 
# 
代碼: 

--- 如果您是 *註冊會員*, 那麼您必須登入和回覆文章後, 才可閱讀 --- 
 

# 
#-----[ OPEN ]----- 
# 
includes/bbcode.php 
# 
#-----[ FIND ]----- 
# 
代碼: 

--- phpBB : The Protected Message is not copied in this quote --- 
 

# 
#-----[ REPLACE WITH ]----- 
# 
代碼: 

--- 這些隱藏訊息, 無法在引言中顯示 --- 
 
# 
#--------[ SAVE/CLOSE ALL FILES ]---------------- 
# 

以下是自動隱藏附加檔案的修改.....(By CAT)======================
以下是自動隱藏附加檔案的修改.....(By CAT)======================
以下是自動隱藏附加檔案的修改.....(By CAT)======================

 

=====<開啟>
  ./include/bbcode.php

=====<尋找>
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;
}
=====<在該部分尋找>
  global $bbcode_tpl;

=====<取代為>
  global $bbcode_tpl, $attvalid;

=====<在該部分尋找>
  // Remove padding, return.
  $text = substr($text, 1);

=====<再下一行加入>
  $attvalid = TRUE;

=====<在該部分尋找>
  $replacements[0] = $bbcode_tpl['show'];

=====<再下一行加入>
  $attvalid = TRUE;

=====<在該部分尋找>
  $replacements[0] = $bbcode_tpl['hide'];

=====<再下一行加入>
  $attvalid = FALSE;

=====<開啟>
  ./attach_mod/displaying.php

=====<尋找>
function display_post_attachments($post_id, $switch_attachment) 
{ 
   global $attach_config, $is_auth, $attvalid; 
		
	if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']))
	{
		return;
	}

	if ($is_auth['auth_download'] && $is_auth['auth_view']  && $attvalid == TRUE  )
	{
		display_attachments($post_id);
	}
	else
	{
		// Display Notice (attachment there but not having permissions to view it)
		// Not included because this would mean template and language file changes (at this stage this is not a wise step. ;))
		display_attachments_notice();
	}
}

=====<在該部分尋找>
  if ($is_auth['auth_download'] && $is_auth['auth_view']  && $valid == TRUE  )

=====<取代為>
  if ($is_auth['auth_download'] && $is_auth['auth_view']  && $attvalid == TRUE  )

=====<開啟>
  ./viewtopic.php

=====<尋找>
$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;}

=====<在該行中尋找>
  $valid = FALSE;

=====<再下一行加入>
  $attvalid = FALSE;

=====<儲存並關閉所有檔案>


=====<選用修改>(要不要改都可以)
=====<開啟>
  ./attach_mod/displaying.php

=====<尋找>
function display_review_attachments($post_id, $switch_attachment, $is_auth)
{
	global $attach_config, $attachments;
		
	if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || (!($is_auth['auth_download'] && $is_auth['auth_view'])) || intval($attach_config['attachment_topic_review']) == 0)
	{
		return;
	}

	@reset($attachments);
	$attachments['_' . $post_id] = get_attachments_from_post($post_id);

	if (sizeof($attachments['_' . $post_id]) == 0)
	{
		return;
	}

	display_attachments($post_id);
	
}

=====<在該行中尋找>
  display_attachments($post_id);

=====<替換為>
  //display_attachments($post_id);//因為在回覆的過程當中, 會漏餡....所以就不顯示了!!!

=====<儲存並關閉所有檔案>
以下是範例圖片
圖檔

請各位多多指教..... :oops: :oops: :oops:
最後由 肥貓 於 2007-07-16 00:13 編輯,總共編輯了 6 次。
肥貓來啦~~~~~(碰!碰!碰!碰!碰!{腳步聲})
頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8510
註冊時間: 2004-04-30 01:54
來自: Taiwan

文章 心靈捕手 »

您不該自居外掛作者, 頂多算是整理者!

雖然您在作者留言, 有提到參考我的修改,
但是卻忽略了提及 ~倉木麻衣~ 的修改.

因為這個合併修改的重點 (前提) 是這個修改:
attachment_mod 2.4.1未登入說明訊息
http://phpbb-tw.net/phpbb/viewtopic.php?p=255061#255061

ps.
鎖定! 並移動至 '非官方外掛討論' 版面
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8510
註冊時間: 2004-04-30 01:54
來自: Taiwan

文章 心靈捕手 »

我將上回的討論, 做了些整理與修改.
http://phpbb-tw.net/phpbb/viewtopic.php?p=259113#259113

發現您有做了點改變:
在文章使用[hide]時...自動隱藏附加檔案...
沒有使用[Hide]時...不隱藏附加檔案


因此, 您可以作者自居無疑! :oops:
只是希望您能再做些修正, 加入 ~倉木麻衣~ 的修改.
http://phpbb-tw.net/phpbb/viewtopic.php?p=255061#255061

ps.
移動回 '非官方外掛' 版面.
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
主題已鎖定

回到「非官方認證外掛」