本帖最后由 friendliness 于 2010-11-21 10:42 编辑
適用版本: Disucz X1 Discuz X1.5 Discuz X1.5 RC
語言編碼: GBK BIG5 UTF_TC UTF_SC
插件作者: Friendliness ( 曾采楓 )
版權所屬: Friendliness ( 曾采楓 )
支持網站: http://test.globalasians.com
插件簡介:Google的 ReCAPTCHA驗證碼 For Discuz X1 Discuz X1.5 Discuz X1.5 RC。
先看效果:
參照原文:http://www.yookoala.idv.hk/en/node/24 僅支持 Discuz!6.0,修改後,使其在Dx1, Dx1.5, Dx1.5 RC 下使用。
具體做法 : 首先在http://www.google.com/recaptcha申請賬號,註冊你的網站,
獲取Public Key和Private Key, 到這裡下載recaptcha-php-1.11.
在/source/include文件夾下新建一個recaptcha文件夾,將下載的recaptchalib.php文件複製到該文件夾內。
打開/source/module/member/member_register.php文件
查找:- $username = dhtmlspecialchars($username);
复制代码
在上面添加:- // recaptcha hack start
- require_once DISCUZ_ROOT.'./source/include/recaptcha/recaptchalib.php';
- $recaptcha_publickey = '這裡替換為你申請到的Public Key';
- $recaptcha_show = recaptcha_get_html($recaptcha_publickey);
- // recaptcha hack end
复制代码 查找:- $username = addslashes(trim(dstripslashes($username)));
复制代码 在上面添加:- // recaptcha hack start
- require_once DISCUZ_ROOT.'./source/include/recaptcha/recaptchalib.php';
- $recaptcha_privatekey = '這裡替換為你申請到Private Key';
- $resp = recaptcha_check_answer ($recaptcha_privatekey,
- $_SERVER["REMOTE_ADDR"],
- $_POST["recaptcha_challenge_field"],
- $_POST["recaptcha_response_field"]);
- if (!$resp->is_valid) {
- // What happens when the CAPTCHA was entered incorrectly
- if ($resp->error = 'incorrect-captcha-sol') {
- $resp->error = "驗證碼輸入不正確,請按"刷新"按鈕重新獲取驗證碼並再試一次。";
- }
- showmessage('reCAPTCHA failed. reCAPTCHA said: ' . trim($resp->error));
- }
- // recaptcha hack end
复制代码 打開template/default/member/register.htm
查找:- <p id="layer_reginfo_b" class="fsb cl">
- <!--{if $_G['setting']['sitemessage'][register]}-->
复制代码 在上面添加:- <!--{if $recaptcha_show}-->
- <label>
- <script type="text/javascript">
- var RecaptchaOptions = {
- theme: 'custom',
- lang: 'en',
- callback: 'Recaptcha.focus_response_field',
- custom_theme_widget: 'recaptcha_widget',
- custom_translations: {
- play_again: "重播",
- cant_hear_this: "下載MP3"} };
- </script>
- <div id="recaptcha_widget" style="display:none">
- <div id="recaptcha_image"></div>
- <div class="recaptcha_only_if_incorrect_sol" style="color:red">輸入驗證碼錯誤,請重試一次。 </div>
- <span class="recaptcha_only_if_image">驗證碼:</span>
- <span class="recaptcha_only_if_audio">輸入您聽到數字:</span>
- <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" /> *
- <span><a href="javascript:Recaptcha.reload()">刷新</a></span>
- <span class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">聲音</a></span>
- <span class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">文字</a></span>
- <span><a href="javascript:Recaptcha.showhelp()">?</a></span>
- <p>$recaptcha_show</p>
- </label>
- <p style="color: blue;">提示: 為提高輸入驗證碼成功率,當您感到驗證碼辨識困難時,</p>
- <p style="color: blue;">請按上面的刷新按鈕重新獲取新的驗證碼,直到您滿意為止。 </p>
- <!--{/if}-->
复制代码 進入管理後台,全局——防灌水設置——驗證碼設置,取消新用戶註冊驗證;
界面——界面設置——啟用浮動窗口——取消註冊窗口浮動
更新緩存,OK。
如果你從未修改過註冊文件,直接用下載的文件覆蓋即可(請務必事先做好備份)。
不想自己改,用下面是修改好的文件,
免費下載:
|