[外掛] Visual confirmation for guests in blog (訪客於網誌回文之確認代碼)

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

版主: 版主管理群

主題已鎖定
頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8510
註冊時間: 2004-04-30 01:54
來自: Taiwan

[外掛] Visual confirmation for guests in blog (訪客於網誌回文之確認代碼)

文章 心靈捕手 »

代碼: 選擇全部

##############################################################
## 外掛名稱: Visual confirmation for guests in blog (訪客於網誌回文之確認代碼)
## 外掛作者: wang5555 < wang55.wang55@msa.hinet.net > (心靈捕手) http://220.134.232.37/
## 外掛描述: 這個外掛, 讓您論壇裡的網誌, 若有訪客欲回文時, 則其必須輸入正確的確認代碼才行.
##
## 外掛版本: 1.0.0
##
## 安裝難度: Easy
## 安裝時間: < 5 Minutes
## 需要編輯的檔案: 2
##               weblog_posting.php
##               weblogs/templates/YOUR_THEME/weblog_posting_body.htm
##
## 附加檔案: 0
##
## 版權聲明: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 
############################################################## 
## 由於安全上的考量, 請檢查: http://phpbb-tw.net/phpbb/index.php 
## 是否有此外掛的最新版本. 
################################################################ 
## 作者留言:
##
##   1. 此外掛於 phpBB 2.0.22 測試無誤.
##
##   2. 修改前提: 您的論壇已經安裝好下面外掛, 且運作正常
##       Blog Mod 0.24b
##       http://phpbb-tw.net/phpbb/viewtopic.php?t=35352
## 
##   3. 此外掛乃參考 Visual Confirmation for Guests 撰寫, 特此銘謝
##       該外掛參考連結: http://www.phpbb.com/community/viewtopic.php?t=266787
##
################################################################
## 外掛歷史:
##
##   2007-07-22 - Version 1.0.0
##  	- 首次發表
##
############################################################## 
## 新增外掛前, 請先備份相關檔案.
############################################################## 

#
#-----[ OPEN ]-----
#
weblog_posting.php

#
#-----[ FIND ]-----
#
	// Always going to be a message that needs to be taken care of
	$message = ( isset($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : '';
	$error_msg = '';

#
#-----[ AFTER, ADD ]-----
#
			// Visual confirmation for guests in blog
			if ( $board_config['enable_confirm'] && !$userdata['session_logged_in'] )
			{
				if ( empty($HTTP_POST_VARS['confirm_id']) || empty($HTTP_POST_VARS['confirm_code']) )
				{
					$error = TRUE;
					$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
				}
				else
				{
					$confirm_id = htmlspecialchars($HTTP_POST_VARS['confirm_id']);
					if (!preg_match('/^[A-Za-z0-9]+$/', $confirm_id))
					{
						$confirm_id = '';
					}
					
					$sql = 'SELECT code 
						FROM ' . CONFIRM_TABLE . " 
						WHERE confirm_id = '$confirm_id' 
							AND session_id = '" . $userdata['session_id'] . "'";
					if (!($result = $db->sql_query($sql)))
					{
						message_die(GENERAL_ERROR, 'Could not obtain confirmation code', __LINE__, __FILE__, $sql);
					}
		
					if ($row = $db->sql_fetchrow($result))
					{
						if ($row['code'] != $HTTP_POST_VARS['confirm_code'])
						{
							$error = TRUE;
							$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
						}
						else
						{
							$sql = 'DELETE FROM ' . CONFIRM_TABLE . " 
								WHERE confirm_id = '$confirm_id' 
									AND session_id = '" . $userdata['session_id'] . "'";
							if (!$db->sql_query($sql))
							{
								message_die(GENERAL_ERROR, 'Could not delete confirmation code', __LINE__, __FILE__, $sql);
							}
						}
					}
					else
					{		
						$error = TRUE;
						$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong'];
					}
					$db->sql_freeresult($result);
				}
			}

#
#-----[ FIND ]-----
#
// Generate smilies listing for page output
generate_smilies('inline', PAGE_POSTING);

#
#-----[ BEFORE, ADD ]-----
#
//
// Visual confirmation for guests in blog
//
$confirm_image = '';
if( !$userdata['session_logged_in'] && (!empty($board_config['enable_confirm'])) )
{
	$sql = 'SELECT session_id 
		FROM ' . SESSIONS_TABLE; 
	if (!($result = $db->sql_query($sql)))
	{
		message_die(GENERAL_ERROR, 'Could not select session data', '', __LINE__, __FILE__, $sql);
	}
	
	if ($row = $db->sql_fetchrow($result))
	{
		$confirm_sql = '';
		do
		{
			$confirm_sql .= (($confirm_sql != '') ? ', ' : '') . "'" . $row['session_id'] . "'";
		}
		while ($row = $db->sql_fetchrow($result));
	
		$sql = 'DELETE FROM ' .  CONFIRM_TABLE . " 
			WHERE session_id NOT IN ($confirm_sql)";
		if (!$db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, 'Could not delete stale confirm data', '', __LINE__, __FILE__, $sql);
		}
	}
	$db->sql_freeresult($result);
	
	$confirm_chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',  'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',  'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9');
	
	list($usec, $sec) = explode(' ', microtime()); 
	mt_srand($sec * $usec); 
	
	$max_chars = count($confirm_chars) - 1;
	$code = '';
	for ($i = 0; $i < 6; $i++)
	{
		$code .= $confirm_chars[mt_rand(0, $max_chars)];
	}
	
	$confirm_id = md5(uniqid($user_ip));
	
	$sql = 'INSERT INTO ' . CONFIRM_TABLE . " (confirm_id, session_id, code) 
		VALUES ('$confirm_id', '". $userdata['session_id'] . "', '$code')";
	if (!$db->sql_query($sql))
	{
		message_die(GENERAL_ERROR, 'Could not insert new confirm code information', '', __LINE__, __FILE__, $sql);
	}
	
	unset($code);
	
	$confirm_image = (@extension_loaded('zlib')) ? '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id") . '" alt="" title="" />' : '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=1") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=2") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=3") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=4") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=5") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=6") . '" alt="" title="" />';
	$hidden_form_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />';
	
	$template->assign_block_vars('switch_confirm', array());
}

#
#-----[ FIND ]-----
#
	'SMILIES_STATUS' => $smilies_status, 

#
#-----[ BEFORE, ADD ]-----
#
	// + Visual confirmation for guests in blog
	'CONFIRM_IMG' => $confirm_image,
	'L_CONFIRM_CODE_IMPAIRED'	=> sprintf($lang['Confirm_code_impaired'], '<a href="mailto:' . $board_config['board_email'] . '">', '</a>'),
	'L_CONFIRM_CODE_EXPLAIN' => $lang['Confirm_code_explain'],
	// - Visual confirmation for guests in blog

#
#-----[ OPEN ]-----
#
weblogs/templates/YOUR_THEME/weblog_posting_body.htm

#
#-----[ FIND ]-----
# ps, 網誌風格或許有異, 但以新增在 submit 之前為要
				  <tr>
					<td>
					  <input type="checkbox" name="disable_replies" {S_DISABLE_REPLIES_CHECKED} />
					</td>
					<td><span class="gen">{L_DISABLE_REPLIES}</span></td>
				  </tr>
				  <!-- END switch_post_entry -->

#
#-----[ AFTER, ADD ]-----
#
				  <!-- Visual Confirmation -->
				  <!-- BEGIN switch_confirm -->
				  <tr>
					<td class="row1" colspan="2" align="center"><span class="gensmall">{L_CONFIRM_CODE_IMPAIRED}</span><br /><br />{CONFIRM_IMG}<br /><br /></td>
				  </tr>
				  <tr> 
					<td class="row1"><span class="gen">{L_CONFIRM_CODE}: * </span><br /><span class="gensmall">{L_CONFIRM_CODE_EXPLAIN}</span></td>
					<td class="row2"><input type="text" class="post" style="width: 200px" name="confirm_code" size="6" maxlength="6" value="" /></td>
				  </tr>
				  <!-- END switch_confirm -->

#
#-----[ SAVE & CLOSE ]-----
#
#End
DEMO:
http://wang5555.dnsfor.me/phpBB2/weblog_pos ... eply&e=182

圖檔
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
主題已鎖定

回到「非官方認證外掛」