2010年5月18日

How to add a custom CAPTCHA to phpBB2

某客戶留下的phpBB2被洗版 解決方法 安裝CAPTCHA方案

翻譯http://www.matthewleverton.com/howto/phpBB2-captcha.html

系統需求:
phpBB2
freecap
PHP 4/5 with GD enabled 確認是否有安裝->(rpm -qa|grep php-gd)
Admin Rights

安裝步驟:
1. 將freecap下載到phpbb網頁資料夾內
cd /phpbb
wget http://www.puremango.co.uk/freecap1.4.1.zip
unzip -a freecap1.4.1.zip
rm freecap1.4.1.zip
mv freecap1.4.1 freecap

2.找到phpBB內的樣式template資料夾 修改下面的profile_add_body.tpl,
例如\phpBB\template\subSilver\profile_add_body.tpl

3.將以下文字貼到profile_add_body.tpl檔案內, 建議是在password那段落的下面
下面的英文Cannot read the image?等,都可以改成你想要顯示的文字

<tr>
<td class="row1"><span class="gen">CAPTCHA Image:</span><br />
<td class="row2">
<img id="freecap" src="/phpBB2/freecap/freecap.php" />
<div style="margin: 0.5em 0;">
<label style="font-size: 10px;" for="captcha">Word in Above Image:</label>
<input id="captcha" name="captcha" type="text" size="10" />
</div>
<div style="font-size: 10px;">
Cannot read the image?
<a href="#" onclick="document.getElementById('freecap').src='/phpBB2/freecap/freecap.php?'+Math.random();">Click Here</a>
to generate a new one.
</div>
</td>
</tr>



4.以下原網頁第7步驟我沒做就OK了 有空再來翻譯..
Edit the phpBB2/includes/usercp_register.php file. (Remember to make a backup copy!) Around line 265, you'll see a block of code that says:
else if ( $mode == 'register' )
{
if ( empty($username) || empty($new_password) || empty($password_confirm) || empty($email) )
{
$error = TRUE;
$error_msg .= ( ( isset($error_msg) ) ? '
' : '' ) . $lang['Fields_empty'];
}
}

You need to add some lines to it, just in front of that closing brace. That section should look like:
else if ( $mode == 'register' )
{
if ( empty($username) || empty($new_password) || empty($password_confirm) || empty($email) )
{
$error = TRUE;
$error_msg .= ( ( isset($error_msg) ) ? '
' : '' ) . $lang['Fields_empty'];
}

session_start();
if (!isset($_POST['captcha']) || !isset($_SESSION['freecap_word_hash']) || $_SESSION['hash_func']($_POST['captcha']) != $_SESSION['freecap_word_hash'])
{
$error = TRUE;
$error_msg .= ( ( isset($error_msg) ) ? '
' : '' ) . "The word you entered did not match the image.";
}
unset($_SESSION['freecap_word_hash']);

}

Note that you are only adding those seven lines in bold!

沒有留言:

張貼留言

追蹤者