1 頁 (共 1 頁)

[外掛]POST PASSWOrDS

發表於 : 2007-02-05 11:02
御津闇慈

代碼: 選擇全部

##############################################################
## 外掛名稱: POST PASSWOrDS(發文密碼)
## 外掛作者: 御津闇慈 < solzxeramsj@gmail.com >
## 外掛描述: 這個外掛, 採用GD函式庫創建一個圖片密碼阻止BOT發文
##
## 外掛版本: 1.0.0
##
## 安裝難度: Easy
## 安裝時間: <10 Minutes
## 需要編輯的檔案:
##               posting.php
##               includes/functions_post.php
##               admin/admin_board.php
##               lang_admin.php
##               lang_main.php
##               posting_body.tpl
##               board_config_body.tpl
## 需要複製的檔案:
##               postpass_img.php
## 附加檔案: 無
## 版權聲明: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## 由於安全上的考量, 請檢查: http://phpbb-tw.net/phpbb/index.php
## 是否有此外掛的最新版本.
################################################################
## 作者留言:
##
##   1. 功能啟動時,發表文章會出現一欄圖片密碼,必須輸入才可以發文
##   
##
##   2. 本外掛採用GD函式庫的簡易功能,假如要讓圖片便的更複雜請自行修改postpass_img.php
##   
##
##   3. 此外掛可以從後台修改密碼類型跟長度
##
##   4. 此外掛是兩三個月之前寫的外掛,大致上應該沒啥問題吧...|||
##
##
################################################################
## 外掛歷史:
##
##   2007-02-05 - Version 1.0.0
##     - 首次發表
##
##############################################################
## 新增外掛前, 請先備份相關檔案.
############################################################## 
#
#-----[ SQL ]------------------------------------------
#

INSERT INTO `phpbb_config` VALUES ('post_pass_code', '3');
INSERT INTO `phpbb_config` VALUES ('post_pass', '4');

#
#-----[ COPY ]------------------------------------------
#
copy root/postpass_img.php to postpass_img.php

#
#-----[ OPEN ]------------------------------------------------ 
#

posting.php

#
#-----[ FIND ]------------------------------------------------ 
#

			$poll_title = ( isset($HTTP_POST_VARS['poll_title']) && $is_auth['auth_pollcreate'] ) ? $HTTP_POST_VARS['poll_title'] : '';
			
#
#-----[ AFTER, ADD ]------------------------------------------ 
#

			// PostWords
			$pass_key = ( !empty($HTTP_POST_VARS['pass_key']) ) ? $HTTP_POST_VARS['pass_key'] : '';
			$post_pass = ( !empty($HTTP_POST_VARS['post_pass']) ) ? $HTTP_POST_VARS['post_pass'] : '';
			// PostWords

#
#-----[ FIND ]------------------------------------------------ 
#

//
// Signature toggle selection
//
if( $user_sig != '' )
{
	$template->assign_block_vars('switch_signature_checkbox', array());
}

#
#-----[ BEFORE, ADD ]----------------------------------------- 
#

//
// PostWords
//
if((!$userdata['session_logged_in'] || $userdata['user_level'] = USER) && $board_config['post_pass_code']!= 0)
{
	$template->assign_block_vars('postpassword', array());
}

#
#-----[ FIND ]------------------------------------------------ 
#

//
// Include page header
//
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

#
#-----[ BEFORE, ADD ]----------------------------------------- 
#

// PostWords
	$length = $board_config['post_pass'];
	switch( $board_config['post_pass_code'])
	{
	case '1':
	$key_chars = '0123456789';
	break;
	case '2':
	$key_chars = 'abcdefghijklmnopqrstuvwxyz';
	break;
	case '3':
	$key_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	break;
	case '4':
	$key_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
	break;
	}
	$rand_max  = strlen($key_chars) - 1;
	
	for ($i = 0; $i < $length; $i++)
	{
	   $rand_pos  = rand(0, $rand_max);
	   $rand_key[] = $key_chars{$rand_pos};
	}
	
	$post_pass = implode('', $rand_key);
	$passcode = append_sid("postpass_img.$phpEx?post_pass=$post_pass");

// PostWords

#
#-----[ FIND ]------------------------------------------------ 
#

//
// Output the data to the template
//
$template->assign_vars(array(
	'USERNAME' => $username,
	'SUBJECT' => $subject,
	'MESSAGE' => $message,

#
#-----[ AFTER, ADD ]------------------------------------------ 
#

	// PostWords
	'POST_PASS' => '<img src="' . $passcode . '">',
	'POST_PASS2' => md5($post_pass),
	'PASS_KEY' => $pass_key,
	'PASS_CODE' => $length,
	// PostWords

#
#-----[ OPEN ]------------------------------------------------ 
#

includes/functions_post.php

#
#-----[ FIND ]------------------------------------------------ 
#

	// Check subject
	if (!empty($subject))
	{
		$subject = htmlspecialchars(trim($subject));
	}
	else if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post']))
	{
		$error_msg .= (!empty($error_msg)) ? '<br />' . $lang['Empty_subject'] : $lang['Empty_subject'];
	}

#
#-----[ AFTER, ADD ]------------------------------------------
#
 
	// Check Post PassWords
	$pass_key2 = md5($pass_key);
	if((strcmp($post_pass ,$pass_key2) && ($userdata['user_level'] = USER || !$userdata['session_logged_in']))&& $board_config['post_pass_code']!= 0)
	{
		$error_msg .= (!empty($error_msg)) ? '<br />' . $lang['Empty_postpassword'] : $lang['Empty_postpassword'];
	}
	// Check topic_types

#
#-----[ OPEN ]------------------------------------------------ 
#

admin/admin_board.php

#
#-----[ FIND ]------------------------------------------------ 
#
$smtp_yes = ( $new['smtp_delivery'] ) ? "checked=\"checked\"" : "";
$smtp_no = ( !$new['smtp_delivery'] ) ? "checked=\"checked\"" : "";

#
#-----[ AFTER, ADD ]------------------------------------------ 
#

$post_pass = $new['post_pass'];
//$post_pass_code = $new['post_pass_code'];

for ($i=0;$i<=4;$i+=1) 
{ 
if ($new['post_pass_code'] == $i ) 
{ 
$checked = 'selected'; 
} else { 
$checked = ''; 
} 
$post_pass_select .= '<option ' . $checked . ' value="'.$i.'">'.$lang['Post_pass_l'][$i].'</option>'; 
} 

#
#-----[ FIND ]------------------------------------------------ 
#

	'SPLIT_STICKY_YES'			=> $split_sticky_yes,
	'SPLIT_STICKY_NO'			=> $split_sticky_no,

#
#-----[ AFTER, ADD ]------------------------------------------ 
#

	'L_POST_PASS_INFO' => $lang['Post_pass_info'],
	'L_POST_PASS_LENGTH' => $lang['Post_pass_length'],
	'POST_CODE_LENGTH'=> $post_pass,
	'POST_PASS_SELECT'=> $post_pass_select,

#
#-----[ OPEN ]------------------------------------------------ 
#

lang_admin.php

#
#-----[ FIND ]------------------------------------------------ 
#

// That's all Folks!
// -------------------------------------------------

#
#-----[ BEFORE, ADD ]----------------------------------------- 
#

$lang['Post_pass_l'] = array(
	'功能關閉',
	'純數字',
	'英文小寫',
	'英文大寫',
	'三種都有',
	);

$lang['Post_pass_length'] = '文章密碼長度';
 
$lang['Post_pass_info']  = '文章密碼類型';

#
#-----[ OPEN ]------------------------------------------------ 
#

lang_main.php

#
#-----[ FIND ]------------------------------------------------ 
#

$lang['Empty_subject'] 

#
#-----[ AFTER, ADD ]------------------------------------------ 
#

$lang['Empty_postpassword'] = '請先確認所輸入的發文驗證密碼是否正確';

#
#-----[ FIND ]------------------------------------------------ 
#

$lang['Flood_Error'] = '嚴禁惡意的快速發文攻擊, 請稍後再試';

#
#-----[ AFTER, ADD ]------------------------------------------ 
#

$lang['Empty_postpassword'] = '請先確認所輸入的發文驗證密碼是否正確';

#
#-----[ OPEN ]------------------------------------------------ 
#

posting_body.tpl

#
#-----[ FIND ]------------------------------------------------ 
#

			  <textarea name="message" rows="15" cols="35" wrap="virtual" style="width:450px" tabindex="3" class="post" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">{MESSAGE}</textarea>
			  
#
#-----[ AFTER, ADD ]------------------------------------------ 
#

			<!-- BEGIN postpassword -->
			<br> 
		  <input type="hidden" class="post" name="post_pass" value="{POST_PASS2}"/>{L_POST_PASS}{POST_PASS}&nbsp;&nbsp;&nbsp;{L_POST_PASS_A}<input type="text" class="post" name="pass_key" size="{PASS_CODE}" maxlength="{PASS_CODE}" value="{PASS_KEY}" />
		  <!-- END postpassword -->

#
#-----[ OPEN ]------------------------------------------------ 
#

board_config_body.tpl

#
#-----[ FIND ]------------------------------------------------ 
#

	<tr>
		<td class="row1">{L_ENABLE_PRUNE}</td>
		<td class="row2"><input type="radio" name="prune_enable" value="1" {PRUNE_YES} /> {L_YES}&nbsp;&nbsp;<input type="radio" name="prune_enable" value="0" {PRUNE_NO} /> {L_NO}</td>
	</tr>

#	
#-----[ AFTER, ADD ]------------------------------------------ 
#

	<tr>
		<td class="row1">{L_POST_PASS_LENGTH}</td>
		<td class="row2"><input name="post_pass" type="text" size="2" maxlength="2" value="{POST_CODE_LENGTH}" /></td>
	</tr>
		<td class="row1">{L_POST_PASS_INFO}</td>
		<td class="row2"><select size="1" name="post_pass_code">{POST_PASS_SELECT}</select></td>
	</tr>
	
# 
#-----[ SAVE/CLOSE ALL FILES ]-------------------------------- 
# 
# EoM
http://imoml.phpbb-tw.com/mods/postpassword.zip