fixed Issue 3632 CAPTCHA 애드온을 회원용과 게시물/댓글 용을 분리

git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@13188 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
bnu 2013-11-08 06:12:29 +00:00
parent 3581db5932
commit a16874dc8a
47 changed files with 960 additions and 273 deletions

View file

@ -19,6 +19,7 @@ if(!class_exists('AddonCaptcha'))
{
var $addon_info;
var $target_acts = NULL;
function setInfo(&$addon_info)
{
@ -55,19 +56,7 @@ if(!class_exists('AddonCaptcha'))
$type = Context::get('captchaType');
$target_acts = array('procBoardInsertDocument', 'procBoardInsertComment', 'procIssuetrackerInsertIssue', 'procIssuetrackerInsertHistory', 'procTextyleInsertComment');
if($this->addon_info->apply_find_account == 'apply')
{
$target_acts[] = 'procMemberFindAccount';
}
if($this->addon_info->apply_resend_auth_mail == 'apply')
{
$target_acts[] = 'procMemberResendAuthMail';
}
if($this->addon_info->apply_signup == 'apply')
{
$target_acts[] = 'procMemberInsert';
}
$this->target_acts = array('procBoardInsertDocument', 'procBoardInsertComment', 'procIssuetrackerInsertIssue', 'procIssuetrackerInsertHistory', 'procTextyleInsertComment');
if(Context::getRequestMethod() != 'XMLRPC' && Context::getRequestMethod() !== 'JSON')
{
@ -85,13 +74,16 @@ if(!class_exists('AddonCaptcha'))
}
else
{
Context::addHtmlHeader('<script> var captchaTargetAct = new Array("' . implode('","', $target_acts) . '"); </script>');
Context::addHtmlHeader('<script>
if(!captchaTargetAct) {var captchaTargetAct = [];}
captchaTargetAct.push("' . implode('","', $this->target_acts) . '");
</script>');
Context::loadFile(array('./addons/captcha/captcha.min.js', 'body', '', null), true);
}
}
// compare session when calling actions such as writing a post or a comment on the board/issue tracker module
if(!$_SESSION['captcha_authed'] && in_array(Context::get('act'), $target_acts))
if(!$_SESSION['captcha_authed'] && in_array(Context::get('act'), $this->target_acts))
{
Context::loadLang('./addons/captcha/lang');
$ModuleHandler->error = "captcha_denied";
@ -309,6 +301,8 @@ if(!class_exists('AddonCaptcha'))
function compareCaptcha()
{
if(!in_array(Context::get('act'), $this->target_acts)) return true;
if($_SESSION['captcha_authed'])
{
return true;

View file

@ -1,9 +1,7 @@
/* procFilter 함수를 가로채서 captcha 이미지 및 폼을 출력 */
var oldExecXml = null;
var calledArgs = null;
(function($){
$(function() {
var captchaXE = null;
function xeCaptcha() {
@ -21,7 +19,6 @@ var calledArgs = null;
break;
}
}
}
if (isSubmitHook)
@ -52,7 +49,7 @@ var calledArgs = null;
var params = new Array();
params['captcha_action'] = 'setCaptchaSession';
params['mid'] = current_mid;
oldExecXml('', '', params, captchaXE.show,new Array('error','message','about_captcha','captcha_reload','captcha_play','cmd_input','cmd_cancel'));
window.oldExecXml('', '', params, captchaXE.show,new Array('error','message','about_captcha','captcha_reload','captcha_play','cmd_input','cmd_cancel'));
});
}
});
@ -114,7 +111,7 @@ var calledArgs = null;
var params = new Array();
params['captcha_action'] = 'setCaptchaSession';
params['mid'] = current_mid;
oldExecXml('','',params, function() {
window.oldExecXml('','',params, function() {
$("#captcha_image").attr("src", current_url.setQuery('captcha_action','captchaImage').setQuery('rnd', (new Date).getTime()));
});
});
@ -139,9 +136,9 @@ var calledArgs = null;
var params = new Array();
params['captcha_action'] = 'setCaptchaSession';
params['mid'] = current_mid;
oldExecXml(module, act, params, captchaXE.show,new Array('error','message','about_captcha','captcha_reload','captcha_play','cmd_input','cmd_cancel'));
window.oldExecXml(module, act, params, captchaXE.show,new Array('error','message','about_captcha','captcha_reload','captcha_play','cmd_input','cmd_cancel'));
} else {
oldExecXml(module, act, params, callback_func, response_tags, callback_func_arg, fo_obj);
window.oldExecXml(module, act, params, callback_func, response_tags, callback_func_arg, fo_obj);
}
return true;
@ -164,9 +161,9 @@ var calledArgs = null;
params['captcha_action'] = 'captchaCompare';
params['mid'] = current_mid;
params['secret_text'] = $('#secret_text').val();
oldExecXml(calledArgs.module,calledArgs.act,params, function() {
window.oldExecXml(calledArgs.module,calledArgs.act,params, function() {
$("#captcha_layer").hide();
oldExecXml(calledArgs.module, calledArgs.act, calledArgs.params, calledArgs.callback_func, calledArgs.response_tags, calledArgs.callback_func_arg, calledArgs.fo_obj);
window.oldExecXml(calledArgs.module, calledArgs.act, calledArgs.params, calledArgs.callback_func, calledArgs.response_tags, calledArgs.callback_func_arg, calledArgs.fo_obj);
} );
};
}
@ -174,8 +171,10 @@ var calledArgs = null;
}
$(window).ready(function(){
oldExecXml = exec_xml;
exec_xml = xeCaptcha().exec;
if(!window.oldExecXml) {
window.oldExecXml = window.exec_xml;
window.exec_xml = xeCaptcha().exec;
}
});
});
})(jQuery);

File diff suppressed because one or more lines are too long

View file

@ -9,7 +9,6 @@
<title xml:lang="zh-TW">圖形驗證</title>
<description xml:lang="ko">
프로그램 글 등록기를 막기 위해 게시판/ issueTracker에서 글/ 댓글을 입력하려 할 때 알파벳을 입력해야 글/댓글이 입력되는 애드온 입니다.
로그인하지 않은 경우에만 해당됩니다.
</description>
<description xml:lang="en">
This addon helps to prevent spam messages to be posted by requesting non-logged-in users to type characters displayed in the image before submitting comments or posts.
@ -33,8 +32,8 @@
<description xml:lang="zh-TW">
可防止機器人程式的垃圾留言,非用戶要發表主題或回覆時,必須要輸入正確圖片中所顯示的文字才能發表。
</description>
<version>1.0</version>
<date>2010-08-19</date>
<version>1.1</version>
<date>2013-11-07</date>
<author email_address="developers@xpressengine.com" link="http://xpressengine.com/">
<name xml:lang="ko">NAVER</name>
@ -115,107 +114,5 @@
<title xml:lang="vi">Luôn sử dụng</title>
</options>
</var>
<var name="apply_find_account" type="select">
<title xml:lang="ko">비밀번호 찾기 적용</title>
<title xml:lang="zh-CN">应用到查找密码功能</title>
<title xml:lang="jp">비밀번호 찾기 적용</title>
<title xml:lang="zh-TW">忘記密碼</title>
<title xml:lang="en">applying to an action finding account</title>
<title xml:lang="ru">applying to an action finding account</title>
<title xml:lang="vi">Khi lấy lại mật khẩu</title>
<description xml:lang="ko">적용으로 하면 비밀번호 찾기 기능에도 적용되어 악의적인 봇(또는 프로그램)에 의한 메일 발송을 막을 수 있습니다.</description>
<description xml:lang="zh-CN">启用此项功能可以有效地拦截以查找密码名义发送的垃圾邮件。</description>
<description xml:lang="jp">적용으로 하면 비밀번호찾기 기능에도 적용되어 악의적인 봇(또는 프로그램)에 의한 메일 발송을 막을 수 있습니다.</description>
<description xml:lang="zh-TW">開啟功能後在忘記密碼時會顯示驗證碼。</description>
<description xml:lang="en">If you set this option as apply, CAPTCHA will work for finding account action, too.</description>
<description xml:lang="ru">If you set this option as apply, CAPTCHA will work for finding account action, too.</description>
<description xml:lang="vi">Nếu áp dụng, khi thành viên cần lấy lại mật khẩu khi lỡ quên, Capcha sẽ hiện thị để xác nhận việc này.</description>
<options value="">
<title xml:lang="ko">적용하지 않음</title>
<title xml:lang="zh-CN">不启用</title>
<title xml:lang="jp">적용하지 않음</title>
<title xml:lang="zh-TW">關閉</title>
<title xml:lang="en">Not apply</title>
<title xml:lang="ru">Not apply</title>
<title xml:lang="vi">Không áp dụng</title>
</options>
<options value="apply">
<title xml:lang="ko">적용</title>
<title xml:lang="zh-CN">启用</title>
<title xml:lang="jp">적용</title>
<title xml:lang="zh-TW">開啟</title>
<title xml:lang="en">Apply</title>
<title xml:lang="ru">Apply</title>
<title xml:lang="vi">Áp dụng</title>
</options>
</var>
<var name="apply_resend_auth_mail" type="select">
<title xml:lang="ko">인증 메일 재발송 적용</title>
<title xml:lang="zh-CN">应用到认证邮件重新发送功能</title>
<title xml:lang="jp">인증 메일 재발송 적용</title>
<title xml:lang="zh-TW">重寄認證信</title>
<title xml:lang="en">apply to an action resending authmail</title>
<title xml:lang="ru">apply to an action resending authmail</title>
<title xml:lang="vi">Khi lấy lại mã kích hoạt</title>
<description xml:lang="ko">적용으로 하면 인증 메일 재발송 기능에도 적용되어 악의적인 봇(또는 프로그램)에 의한 메일 발송을 막을 수 있습니다.</description>
<description xml:lang="zh-CN">启用此项功能可以有效地拦截以重新发送认证邮件名义发送的垃圾邮件。</description>
<description xml:lang="jp">적용으로 하면 인증 메일 재발송 기능에도 적용되어 악의적인 봇(또는 프로그램)에 의한 메일 발송을 막을 수 있습니다.</description>
<description xml:lang="zh-TW">開啟功能後在重寄認證信時會顯示驗證碼。</description>
<description xml:lang="en">If you set this option as apply, CAPTCHA will work for resending authmail action, too.</description>
<description xml:lang="ru">If you set this option as apply, CAPTCHA will work for resending authmail action, too.</description>
<description xml:lang="vi">Nếu áp dụng, khi thành viên cần lấy lại mã kích hoạt thành viên, Capcha sẽ hiện thị để xác nhận việc này.</description>
<options value="">
<title xml:lang="ko">적용하지 않음</title>
<title xml:lang="zh-CN">不启用</title>
<title xml:lang="jp">적용하지 않음</title>
<title xml:lang="zh-TW">關閉</title>
<title xml:lang="en">Not apply</title>
<title xml:lang="ru">Not apply</title>
<title xml:lang="vi">Không áp dụng</title>
</options>
<options value="apply">
<title xml:lang="ko">적용</title>
<title xml:lang="zh-CN">启用</title>
<title xml:lang="jp">적용</title>
<title xml:lang="zh-TW">開啟</title>
<title xml:lang="en">Apply</title>
<title xml:lang="ru">Apply</title>
<title xml:lang="vi">Áp dụng</title>
</options>
</var>
<var name="apply_signup" type="select">
<title xml:lang="ko">회원 가입 적용</title>
<title xml:lang="zh-CN">应用到用户注册表单</title>
<title xml:lang="jp">인증 메일 재발송 적용</title>
<title xml:lang="zh-TW">會員註冊</title>
<title xml:lang="en">Apply to member signup</title>
<title xml:lang="ru">Apply to member signup</title>
<title xml:lang="vi">Apply to member signup</title>
<description xml:lang="ko">적용으로 하면 회원가입 기능에도 적용되어 악의적인 봇(또는 프로그램)의 회원가입을 막을 수 있습니다.</description>
<description xml:lang="zh-CN">启用此项功能可以有效地拦截自动注册软件的施虐。</description>
<description xml:lang="jp">적용으로 하면 회원가입 기능에도 적용되어 악의적인 봇(또는 프로그램)의 회원가입을 막을 수 있습니다.</description>
<description xml:lang="zh-TW">開啟功能後在註冊時會顯示驗證碼。</description>
<description xml:lang="en">If you set this option as apply, CAPTCHA will work for signup action, too.</description>
<description xml:lang="ru">If you set this option as apply, CAPTCHA will work for signup action, too.</description>
<description xml:lang="vi">If you set this option as apply, CAPTCHA will work for signup action, too.</description>
<options value="">
<title xml:lang="ko">적용하지 않음</title>
<title xml:lang="zh-CN">不启用</title>
<title xml:lang="jp">적용하지 않음</title>
<title xml:lang="zh-TW">關閉</title>
<title xml:lang="en">Not apply</title>
<title xml:lang="ru">Not apply</title>
<title xml:lang="vi">Không áp dụng</title>
</options>
<options value="apply">
<title xml:lang="ko">적용</title>
<title xml:lang="zh-CN">启用</title>
<title xml:lang="jp">적용</title>
<title xml:lang="zh-TW">開啟</title>
<title xml:lang="en">Apply</title>
<title xml:lang="ru">Apply</title>
<title xml:lang="vi">Áp dụng</title>
</options>
</var>
</extra_vars>
</addon>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,180 @@
/* procFilter 함수를 가로채서 captcha 이미지 및 폼을 출력 */
var calledArgs = null;
(function($){
$(function() {
var captchaXE = null;
function xeCaptcha() {
$('form').each(function(i)
{
var isSubmitHook = false;
if (!$(this).attr('onsubmit') || $(this).attr('onsubmit').indexOf('procFilter') < 0)
{
var act = $(this).find('input[name=act]').val()
for(var i = 0; i<captchaTargetAct.length; i++)
{
if(captchaTargetAct[i] == act)
{
isSubmitHook = true;
break;
}
}
}
if (isSubmitHook)
{
$(this).append('<input type="hidden" name="captchaType" value="inline" />');
if(!$(this).find('input[name=error_return_url]'))
$(this).append('<input type="hidden" name="error_return_url" value="'+current_url+'" />');
$(this).submit(function(event){
if ($(this).find('input[name=secret_text]').val())
{
return true;
}
event.preventDefault();
var self = this;
$('#captcha_layer form')
.submit(function(e){
e.preventDefault();
if(!$('#secret_text').val()){
$(this).find('input[type=text]').val('').focus();
return false;
}
$(self).append('<input type="hidden" name="secret_text" value="'+ $('#secret_text').val() +'" />');
$(self).submit();
});
var params = new Array();
params['captcha_action'] = 'setCaptchaSession';
params['mid'] = current_mid;
window.oldExecXml('', '', params, captchaXE.show,new Array('error','message','about_captcha','captcha_reload','captcha_play','cmd_input','cmd_cancel'));
});
}
});
var body = $(document.body);
var captchaIma;
if (!captchaXE) {
var fc_isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var fc_isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var fc_isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var _swfURL_ = request_uri + 'addons/captcha/swf/play.swf';
if(fc_isIE && fc_isWin && !fc_isOpera){
_object_ ='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="0" height="0" id="captcha_audio" align="middle">';
_object_ += '<param name="allowScriptAccess" value="always" />';
_object_ += '<param name="quality" value="high" />';
_object_ += '<param name="movie" value="'+_swfURL_+'" />';
_object_ += '<param name="wmode" value="window" />';
_object_ += '<param name="allowFullScreen" value="false">';
_object_ += '<param name="bgcolor" value="#fffff" />';
_object_ += '</object>';
}else{
_object_ = '<embed src="'+_swfURL_+'" quality="high" wmode="window" allowFullScreen="false" bgcolor="#ffffff" width="0" height="0" name="captcha_audio" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
}
captchaXE = $('<div id="captcha_layer" style="position:fixed; top:0; left:0; width:100%; height:100%;display:none;z-index:10">').appendTo(document.body);
var top_left = 'margin:-105px 0 0 -105px; top:50%; left:50%;';
if(screen.width<480) { top_left = ''; }
var $div = $('<div style="z-index:1000;position:absolute; width:310px;' + top_left + ' background:#fff; border:3px solid #ccc;">'+
'<form method="post" action="">'+
'<div style="position:relative; margin:25px 20px 15px 20px">'+
'<img src="about:blank" id="captcha_image" alt="CAPTCHA" width="240" height="50" style="display:block; width:240px; height:50px; border:1px solid #b0b0b0" />'+
'<button type="button" class="reload" title="" style="position:absolute; top:0; left:245px; width:25px; height:25px; padding:0; overflow:visible; border:1px solid #575757; background:#747474 url('+request_uri + 'addons/captcha/img/icon.gif) no-repeat center 5px;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px; cursor:pointer;box-shadow:0 0 3px #444 inset;-moz-box-shadow:0 0 3px #444 inset;-webkit-box-shadow:0 0 3px #444 inset;"></button>'+
'<button type="button" class="play" title="" style="position:absolute; top:27px; left:245px; width:25px; height:25px; padding:0; overflow:visible; border:1px solid #575757; background:#747474 url('+request_uri + 'addons/captcha/img/icon.gif) no-repeat center -20px;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px; cursor:pointer;box-shadow:0 0 3px #444 inset;-moz-box-shadow:0 0 3px #444 inset;-webkit-box-shadow:0 0 3px #444 inset;"></button>'+
'</div>'+
'<label id="captchaAbout" for="captcha" style="display:block; border-top:1px dashed #c5c5c5; padding:15px 0; margin:0 20px; font-size:12px; color:#5f5f5f;"></label>'+
'<input name="" type="text" id="secret_text" style="ime-mode:inactive;margin:0 20px; width:232px; border:1px solid #bdbdbd; padding:3px 4px; font-size:18px; font-weight:bold;" />'+
'<div style="margin:20px; border-top:1px dashed #c5c5c5; padding:15px 0 0 0; text-align:center">'+
'<button type="submit" style="height:31px; line-height:31px; padding:0 15px; margin:0 2px; font-size:12px; font-weight:bold; color:#fff; overflow:visible; border:1px solid #5c8a16; background:#6faa13;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px; cursor:pointer;box-shadow:0 0 3px #666 inset;-moz-box-shadow:0 0 3px #666 inset;-webkit-box-shadow:0 0 3px #666 inset;"></button>'+
'<button type="button" class="cancel" style="height:31px; line-height:31px; padding:0 15px; margin:0 2px; font-size:12px; font-weight:bold; color:#fff; overflow:visible; border:1px solid #575757; background:#747474;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px; cursor:pointer;box-shadow:0 0 3px #444 inset;-moz-box-shadow:0 0 3px #444 inset;-webkit-box-shadow:0 0 3px #444 inset;"></button>'+
'</div>'+
'</form>'+_object_ +
'</div>').appendTo(captchaXE);
$div.find('button.cancel')
.click(function(){ $('#captcha_layer').hide(); });
$div.find('button.play')
.click(function(){
var swf = window['captcha_audio'] || document['captcha_audio'];
var audio = current_url.setQuery('captcha_action','captchaAudio').setQuery('rnd', (new Date).getTime());
$div.find('input[type=text]').focus();
swf.setSoundTarget(audio,'1');
});
$div.find('button.reload')
.click(function(){
var params = new Array();
params['captcha_action'] = 'setCaptchaSession';
params['mid'] = current_mid;
window.oldExecXml('','',params, function() {
$("#captcha_image").attr("src", current_url.setQuery('captcha_action','captchaImage').setQuery('rnd', (new Date).getTime()));
});
});
captchaXE.exec = function(module, act, params, callback_func, response_tags, callback_func_arg, fo_obj) {
var doCheck = false;
$.each(captchaTargetAct || {}, function(key,val){ if (val == act){ doCheck = true; return false; } });
if (doCheck) { /* captcha 를 사용하는 경우 */
$('#captcha_layer form')
.submit(function(e){
e.preventDefault();
if(!$('#secret_text').val()){
$(this).find('input[type=text]').val('').focus();
return false;
}
captchaXE.compare(); return false;
});
calledArgs = {'module':module,'act':act,'params':params,'callback_func':callback_func,'response_tags':response_tags,'callback_func_arg':callback_func_arg,'fo_obj':fo_obj};
var params = new Array();
params['captcha_action'] = 'setCaptchaSession';
params['mid'] = current_mid;
window.oldExecXml(module, act, params, captchaXE.show,new Array('error','message','about_captcha','captcha_reload','captcha_play','cmd_input','cmd_cancel'));
} else {
window.oldExecXml(module, act, params, callback_func, response_tags, callback_func_arg, fo_obj);
}
return true;
};
captchaXE.show = function(ret_obj) {
$('#captcha_layer').show();
$("#captchaAbout").html(ret_obj['about_captcha']);
$("#captcha_layer .reload").attr('title',ret_obj['captcha_reload']);
$("#captcha_layer .play").attr('title',ret_obj['captcha_play']);
$("#captcha_layer button[type=submit]").html(ret_obj['cmd_input']);
$("#captcha_layer button.cancel").html(ret_obj['cmd_cancel']);
$("#captcha_image").attr("src", current_url.setQuery('captcha_action','captchaImage').setQuery('rnd', (new Date).getTime()));
$div.find('input[type=text]').val('').focus();
$('html, body').css('height','100%');
};
captchaXE.compare = function(e) {
var params = new Array();
params['captcha_action'] = 'captchaCompare';
params['mid'] = current_mid;
params['secret_text'] = $('#secret_text').val();
window.oldExecXml(calledArgs.module,calledArgs.act,params, function() {
$("#captcha_layer").hide();
window.oldExecXml(calledArgs.module, calledArgs.act, calledArgs.params, calledArgs.callback_func, calledArgs.response_tags, calledArgs.callback_func_arg, calledArgs.fo_obj);
} );
};
}
return captchaXE;
}
$(window).ready(function(){
if(!window.oldExecXml) {
window.oldExecXml = window.exec_xml;
window.exec_xml = xeCaptcha().exec;
}
});
});
})(jQuery);

2
addons/captcha_member/captcha.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,412 @@
<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
if(!defined("__XE__")) exit();
/**
* @file captcha.addon.php
* @author NAVER (developers@xpressengine.com)
* @brief Captcha for a particular action
* English alphabets and voice verification added
* */
if(!class_exists('AddonMemberCaptcha'))
{
// On the mobile mode, XE Core does not load jquery and xe.js as normal.
Context::loadFile(array('./common/js/jquery.min.js', 'head', NULL, -100000), true);
Context::loadFile(array('./common/js/xe.min.js', 'head', NULL, -100000), true);
class AddonMemberCaptcha
{
var $addon_info;
var $target_acts = NULL;
function setInfo(&$addon_info)
{
$this->addon_info = $addon_info;
}
function before_module_proc()
{
// if($_SESSION['member_captcha_authed'])
// {
unset($_SESSION['member_captcha_authed']);
// }
}
function before_module_init(&$ModuleHandler)
{
$logged_info = Context::get('logged_info');
if($logged_info->is_admin == 'Y' || $logged_info->is_site_admin)
{
return false;
}
// if($this->addon_info->target != 'all' && Context::get('is_logged'))
// {
// return false;
// }
if($_SESSION['XE_VALIDATOR_ERROR'] == -1)
{
$_SESSION['member_captcha_authed'] = false;
}
if($_SESSION['member_captcha_authed'])
{
return false;
}
$type = Context::get('captchaType');
$this->target_acts = array();
if($this->addon_info->apply_find_account == 'apply')
{
$this->target_acts[] = 'procMemberFindAccount';
}
if($this->addon_info->apply_resend_auth_mail == 'apply')
{
$this->target_acts[] = 'procMemberResendAuthMail';
}
if($this->addon_info->apply_signup == 'apply')
{
$this->target_acts[] = 'procMemberInsert';
}
if(Context::getRequestMethod() != 'XMLRPC' && Context::getRequestMethod() !== 'JSON')
{
if($type == 'inline')
{
if(!$this->compareCaptcha())
{
Context::loadLang('./addons/captcha_member/lang');
$_SESSION['XE_VALIDATOR_ERROR'] = -1;
$_SESSION['XE_VALIDATOR_MESSAGE'] = Context::getLang('captcha_denied');
$_SESSION['XE_VALIDATOR_MESSAGE_TYPE'] = 'error';
$_SESSION['XE_VALIDATOR_RETURN_URL'] = Context::get('error_return_url');
$ModuleHandler->_setInputValueToSession();
}
}
else
{
Context::addHtmlHeader('<script>
if(!captchaTargetAct) {var captchaTargetAct = [];}
captchaTargetAct.push("' . implode('","', $this->target_acts) . '");
</script>');
Context::loadFile(array('./addons/captcha_member/captcha.min.js', 'body', '', null), true);
}
}
// compare session when calling actions such as writing a post or a comment on the board/issue tracker module
if(!$_SESSION['member_captcha_authed'] && in_array(Context::get('act'), $this->target_acts))
{
Context::loadLang('./addons/captcha_member/lang');
$ModuleHandler->error = "captcha_denied";
}
return true;
}
function createKeyword()
{
$type = Context::get('captchaType');
if($type == 'inline' && $_SESSION['captcha_keyword'])
{
return;
}
$arr = range('A', 'Y');
shuffle($arr);
$arr = array_slice($arr, 0, 6);
$_SESSION['captcha_keyword'] = join('', $arr);
}
function before_module_init_setCaptchaSession()
{
if($_SESSION['member_captcha_authed'])
{
return false;
}
// Load language files
Context::loadLang(_XE_PATH_ . 'addons/captcha_member/lang');
// Generate keywords
$this->createKeyword();
$target = Context::getLang('target_captcha');
header("Content-Type: text/xml; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
printf("<response>\r\n <error>0</error>\r\n <message>success</message>\r\n <about_captcha><![CDATA[%s]]></about_captcha>\r\n <captcha_reload><![CDATA[%s]]></captcha_reload>\r\n <captcha_play><![CDATA[%s]]></captcha_play>\r\n <cmd_input><![CDATA[%s]]></cmd_input>\r\n <cmd_cancel><![CDATA[%s]]></cmd_cancel>\r\n </response>"
, Context::getLang('about_captcha')
, Context::getLang('captcha_reload')
, Context::getLang('captcha_play')
, Context::getLang('cmd_input')
, Context::getLang('cmd_cancel')
);
Context::close();
exit();
}
function before_module_init_captchaImage()
{
if($_SESSION['member_captcha_authed'])
{
return false;
}
if(Context::get('renew'))
{
$this->createKeyword();
}
$keyword = $_SESSION['captcha_keyword'];
$im = $this->createCaptchaImage($keyword);
header("Cache-Control: ");
header("Pragma: ");
header("Content-Type: image/png");
imagepng($im);
imagedestroy($im);
Context::close();
exit();
}
function createCaptchaImage($string)
{
$arr = array();
for($i = 0, $c = strlen($string); $i < $c; $i++)
{
$arr[] = $string{$i};
}
// Font site
$w = 18;
$h = 25;
// Character length
$c = count($arr);
// Character image
$im = array();
// Create an image by total size
$im[] = imagecreate(($w + 2) * count($arr), $h);
$deg = range(-30, 30);
shuffle($deg);
// Create an image for each letter
foreach($arr as $i => $str)
{
$im[$i + 1] = @imagecreate($w, $h);
$background_color = imagecolorallocate($im[$i + 1], 255, 255, 255);
$text_color = imagecolorallocate($im[$i + 1], 0, 0, 0);
// Control font size
$ran = range(1, 20);
shuffle($ran);
if(function_exists('imagerotate'))
{
imagestring($im[$i + 1], (array_pop($ran) % 3) + 3, 2, (array_pop($ran) % 8), $str, $text_color);
$im[$i + 1] = imagerotate($im[$i + 1], array_pop($deg), 0);
$background_color = imagecolorallocate($im[$i + 1], 255, 255, 255);
imagecolortransparent($im[$i + 1], $background_color);
}
else
{
imagestring($im[$i + 1], (array_pop($ran) % 3) + 3, 2, (array_pop($ran) % 4), $str, $text_color);
}
}
// Combine images of each character
for($i = 1; $i < count($im); $i++)
{
imagecopy($im[0], $im[$i], (($w + 2) * ($i - 1)), 0, 0, 0, $w, $h);
imagedestroy($im[$i]);
}
// Larger image
$big_count = 2;
$big = imagecreatetruecolor(($w + 2) * $big_count * $c, $h * $big_count);
imagecopyresized($big, $im[0], 0, 0, 0, 0, ($w + 2) * $big_count * $c, $h * $big_count, ($w + 2) * $c, $h);
imagedestroy($im[0]);
if(function_exists('imageantialias'))
{
imageantialias($big, true);
}
// Background line
$line_color = imagecolorallocate($big, 0, 0, 0);
$w = ($w + 2) * $big_count * $c;
$h = $h * $big_count;
$d = array_pop($deg);
for($i = -abs($d); $i < $h + abs($d); $i = $i + 7)
{
imageline($big, 0, $i + $d, $w, $i, $line_color);
}
$x = range(0, ($w - 10));
shuffle($x);
for($i = 0; $i < 200; $i++)
{
imagesetpixel($big, $x[$i] % $w, $x[$i + 1] % $h, $line_color);
}
return $big;
}
function before_module_init_captchaAudio()
{
if($_SESSION['member_captcha_authed'])
{
return false;
}
$keyword = strtoupper($_SESSION['captcha_keyword']);
$data = $this->createCaptchaAudio($keyword);
header('Content-type: audio/mpeg');
header("Content-Disposition: attachment; filename=\"captcha_audio.mp3\"");
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Expires: Sun, 1 Jan 2000 12:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
header('Content-Length: ' . strlen($data));
echo $data;
Context::close();
exit();
}
function createCaptchaAudio($string)
{
$data = '';
$_audio = './addons/captcha_member/audio/F_%s.mp3';
for($i = 0, $c = strlen($string); $i < $c; $i++)
{
$_data = FileHandler::readFile(sprintf($_audio, $string{$i}));
$start = rand(5, 68); // Random start in 4-byte header and 64 byte data
$datalen = strlen($_data) - $start - 256; // Last unchanged 256 bytes
for($j = $start; $j < $datalen; $j+=64)
{
$ch = ord($_data{$j});
if($ch < 9 || $ch > 119)
{
continue;
}
$_data{$j} = chr($ch + rand(-8, 8));
}
$data .= $_data;
}
return $data;
}
function compareCaptcha()
{
if(!in_array(Context::get('act'), $this->target_acts)) return true;
if($_SESSION['member_captcha_authed'])
{
return true;
}
if(strtoupper($_SESSION['captcha_keyword']) == strtoupper(Context::get('secret_text')))
{
$_SESSION['member_captcha_authed'] = true;
return true;
}
unset($_SESSION['member_captcha_authed']);
return false;
}
function before_module_init_captchaCompare()
{
if(!$this->compareCaptcha())
{
return false;
}
header("Content-Type: text/xml; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
print("<response>\r\n<error>0</error>\r\n<message>success</message>\r\n</response>");
Context::close();
exit();
}
function inlineDisplay()
{
unset($_SESSION['member_captcha_authed']);
$this->createKeyword();
$swfURL = getUrl() . 'addons/captcha_member/swf/play.swf';
Context::unloadFile('./addons/captcha_member/captcha.min.js');
Context::loadFile(array('./addons/captcha_member/inline_captcha.js', 'body'));
global $lang;
$tags = <<<EOD
<img src="%s" id="captcha_image" alt="CAPTCHA" width="240" height="50" style="width:240px; height:50px; border:1px solid #b0b0b0" />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="0" height="0" id="captcha_audio" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="movie" value="%s" />
<param name="wmode" value="window" />
<param name="allowFullScreen" value="false">
<param name="bgcolor" value="#fffff" />
<embed src="%s" quality="high" wmode="window" allowFullScreen="false" bgcolor="#ffffff" width="0" height="0" name="captcha_audio" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
<button type="button" class="captchaReload text">%s</button>
<button type="button" class="captchaPlay text">%s</button><br />
<input type="hidden" name="captchaType" value="inline" />
<input name="secret_text" type="text" id="secret_text" />
EOD;
$tags = sprintf($tags, getUrl('captcha_action', 'captchaImage', 'rand', mt_rand(10000, 99999))
, $swfURL
, $swfURL
, $lang->reload
, $lang->play);
return $tags;
}
}
$GLOBALS['__AddonMemberCaptcha__'] = new AddonMemberCaptcha;
$GLOBALS['__AddonMemberCaptcha__']->setInfo($addon_info);
Context::set('oMemberCaptcha', $GLOBALS['__AddonMemberCaptcha__']);
}
$oAddonMemberCaptcha = &$GLOBALS['__AddonMemberCaptcha__'];
if(method_exists($oAddonMemberCaptcha, $called_position))
{
if(!call_user_func_array(array(&$oAddonMemberCaptcha, $called_position), array(&$this)))
{
return false;
}
}
$addon_act = Context::get('captcha_action');
if($addon_act && method_exists($oAddonMemberCaptcha, $called_position . '_' . $addon_act))
{
if(!call_user_func_array(array(&$oAddonMemberCaptcha, $called_position . '_' . $addon_act), array(&$this)))
{
return false;
}
}
/* End of file captcha_member.addon.php */
/* Location: ./addons/captcha_member/captcha_member.addon.php */

View file

@ -0,0 +1,155 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon version="0.2">
<title xml:lang="ko">Captcha Member 애드온</title>
<title xml:lang="en">CAPTCHA Member</title>
<title xml:lang="vi">Captcha Member Addon</title>
<title xml:lang="zh-CN">验证码插件</title>
<title xml:lang="jp">Captchaアドオン</title>
<title xml:lang="ru">Аддон Captcha</title>
<title xml:lang="zh-TW">圖形驗證</title>
<description xml:lang="ko">
회원 가입 및 비밀번호 찾기, 인증메일 재발송을 요청할 때 알파벳을 입력하도록 하여 프로그램 등록기를 막는 애드온 입니다.
적용/비적용 대상 모듈을 지정하지 않아야 정상적으로 동작합니다.
</description>
<description xml:lang="en">
회원 가입 및 비밀번호 찾기, 인증메일 재발송을 요청할 때 알파벳을 입력하도록 하여 프로그램 등록기를 막는 애드온 입니다.
적용/비적용 대상 모듈을 지정하지 않아야 정상적으로 동작합니다.
</description>
<description xml:lang="vi">
회원 가입 및 비밀번호 찾기, 인증메일 재발송을 요청할 때 알파벳을 입력하도록 하여 프로그램 등록기를 막는 애드온 입니다.
적용/비적용 대상 모듈을 지정하지 않아야 정상적으로 동작합니다.
</description>
<description xml:lang="zh-CN">
회원 가입 및 비밀번호 찾기, 인증메일 재발송을 요청할 때 알파벳을 입력하도록 하여 프로그램 등록기를 막는 애드온 입니다.
적용/비적용 대상 모듈을 지정하지 않아야 정상적으로 동작합니다.
</description>
<description xml:lang="jp">
회원 가입 및 비밀번호 찾기, 인증메일 재발송을 요청할 때 알파벳을 입력하도록 하여 프로그램 등록기를 막는 애드온 입니다.
적용/비적용 대상 모듈을 지정하지 않아야 정상적으로 동작합니다.
</description>
<description xml:lang="ru">
회원 가입 및 비밀번호 찾기, 인증메일 재발송을 요청할 때 알파벳을 입력하도록 하여 프로그램 등록기를 막는 애드온 입니다.
적용/비적용 대상 모듈을 지정하지 않아야 정상적으로 동작합니다.
</description>
<description xml:lang="zh-TW">
회원 가입 및 비밀번호 찾기, 인증메일 재발송을 요청할 때 알파벳을 입력하도록 하여 프로그램 등록기를 막는 애드온 입니다.
적용/비적용 대상 모듈을 지정하지 않아야 정상적으로 동작합니다.
</description>
<version>1.0</version>
<date>2013-11-07</date>
<author email_address="developers@xpressengine.com" link="http://xpressengine.com/">
<name xml:lang="ko">NAVER</name>
<name xml:lang="zh-CN">NAVER</name>
<name xml:lang="jp">NAVER</name>
<name xml:lang="zh-TW">NAVER</name>
<name xml:lang="en">NAVER</name>
<name xml:lang="ru">NAVER</name>
<name xml:lang="vi">NAVER</name>
</author>
<extra_vars>
<var name="apply_signup" type="select">
<title xml:lang="ko">회원 가입 적용</title>
<title xml:lang="zh-CN">应用到用户注册表单</title>
<title xml:lang="jp">인증 메일 재발송 적용</title>
<title xml:lang="zh-TW">會員註冊</title>
<title xml:lang="en">Apply to member signup</title>
<title xml:lang="ru">Apply to member signup</title>
<title xml:lang="vi">Apply to member signup</title>
<description xml:lang="ko">적용으로 하면 회원가입 기능에도 적용되어 악의적인 봇(또는 프로그램)의 회원가입을 막을 수 있습니다.</description>
<description xml:lang="zh-CN">启用此项功能可以有效地拦截自动注册软件的施虐。</description>
<description xml:lang="jp">적용으로 하면 회원가입 기능에도 적용되어 악의적인 봇(또는 프로그램)의 회원가입을 막을 수 있습니다.</description>
<description xml:lang="zh-TW">開啟功能後在註冊時會顯示驗證碼。</description>
<description xml:lang="en">If you set this option as apply, CAPTCHA will work for signup action, too.</description>
<description xml:lang="ru">If you set this option as apply, CAPTCHA will work for signup action, too.</description>
<description xml:lang="vi">If you set this option as apply, CAPTCHA will work for signup action, too.</description>
<options value="">
<title xml:lang="ko">적용하지 않음</title>
<title xml:lang="zh-CN">不启用</title>
<title xml:lang="jp">적용하지 않음</title>
<title xml:lang="zh-TW">關閉</title>
<title xml:lang="en">Not apply</title>
<title xml:lang="ru">Not apply</title>
<title xml:lang="vi">Không áp dụng</title>
</options>
<options value="apply">
<title xml:lang="ko">적용</title>
<title xml:lang="zh-CN">启用</title>
<title xml:lang="jp">적용</title>
<title xml:lang="zh-TW">開啟</title>
<title xml:lang="en">Apply</title>
<title xml:lang="ru">Apply</title>
<title xml:lang="vi">Áp dụng</title>
</options>
</var>
<var name="apply_find_account" type="select">
<title xml:lang="ko">비밀번호 찾기 적용</title>
<title xml:lang="zh-CN">应用到查找密码功能</title>
<title xml:lang="jp">비밀번호 찾기 적용</title>
<title xml:lang="zh-TW">忘記密碼</title>
<title xml:lang="en">applying to an action finding account</title>
<title xml:lang="ru">applying to an action finding account</title>
<title xml:lang="vi">Khi lấy lại mật khẩu</title>
<description xml:lang="ko">적용으로 하면 비밀번호 찾기 기능에도 적용되어 악의적인 봇(또는 프로그램)에 의한 메일 발송을 막을 수 있습니다.</description>
<description xml:lang="zh-CN">启用此项功能可以有效地拦截以查找密码名义发送的垃圾邮件。</description>
<description xml:lang="jp">적용으로 하면 비밀번호찾기 기능에도 적용되어 악의적인 봇(또는 프로그램)에 의한 메일 발송을 막을 수 있습니다.</description>
<description xml:lang="zh-TW">開啟功能後在忘記密碼時會顯示驗證碼。</description>
<description xml:lang="en">If you set this option as apply, CAPTCHA will work for finding account action, too.</description>
<description xml:lang="ru">If you set this option as apply, CAPTCHA will work for finding account action, too.</description>
<description xml:lang="vi">Nếu áp dụng, khi thành viên cần lấy lại mật khẩu khi lỡ quên, Capcha sẽ hiện thị để xác nhận việc này.</description>
<options value="">
<title xml:lang="ko">적용하지 않음</title>
<title xml:lang="zh-CN">不启用</title>
<title xml:lang="jp">적용하지 않음</title>
<title xml:lang="zh-TW">關閉</title>
<title xml:lang="en">Not apply</title>
<title xml:lang="ru">Not apply</title>
<title xml:lang="vi">Không áp dụng</title>
</options>
<options value="apply">
<title xml:lang="ko">적용</title>
<title xml:lang="zh-CN">启用</title>
<title xml:lang="jp">적용</title>
<title xml:lang="zh-TW">開啟</title>
<title xml:lang="en">Apply</title>
<title xml:lang="ru">Apply</title>
<title xml:lang="vi">Áp dụng</title>
</options>
</var>
<var name="apply_resend_auth_mail" type="select">
<title xml:lang="ko">인증 메일 재발송 적용</title>
<title xml:lang="zh-CN">应用到认证邮件重新发送功能</title>
<title xml:lang="jp">인증 메일 재발송 적용</title>
<title xml:lang="zh-TW">重寄認證信</title>
<title xml:lang="en">apply to an action resending authmail</title>
<title xml:lang="ru">apply to an action resending authmail</title>
<title xml:lang="vi">Khi lấy lại mã kích hoạt</title>
<description xml:lang="ko">적용으로 하면 인증 메일 재발송 기능에도 적용되어 악의적인 봇(또는 프로그램)에 의한 메일 발송을 막을 수 있습니다.</description>
<description xml:lang="zh-CN">启用此项功能可以有效地拦截以重新发送认证邮件名义发送的垃圾邮件。</description>
<description xml:lang="jp">적용으로 하면 인증 메일 재발송 기능에도 적용되어 악의적인 봇(또는 프로그램)에 의한 메일 발송을 막을 수 있습니다.</description>
<description xml:lang="zh-TW">開啟功能後在重寄認證信時會顯示驗證碼。</description>
<description xml:lang="en">If you set this option as apply, CAPTCHA will work for resending authmail action, too.</description>
<description xml:lang="ru">If you set this option as apply, CAPTCHA will work for resending authmail action, too.</description>
<description xml:lang="vi">Nếu áp dụng, khi thành viên cần lấy lại mã kích hoạt thành viên, Capcha sẽ hiện thị để xác nhận việc này.</description>
<options value="">
<title xml:lang="ko">적용하지 않음</title>
<title xml:lang="zh-CN">不启用</title>
<title xml:lang="jp">적용하지 않음</title>
<title xml:lang="zh-TW">關閉</title>
<title xml:lang="en">Not apply</title>
<title xml:lang="ru">Not apply</title>
<title xml:lang="vi">Không áp dụng</title>
</options>
<options value="apply">
<title xml:lang="ko">적용</title>
<title xml:lang="zh-CN">启用</title>
<title xml:lang="jp">적용</title>
<title xml:lang="zh-TW">開啟</title>
<title xml:lang="en">Apply</title>
<title xml:lang="ru">Apply</title>
<title xml:lang="vi">Áp dụng</title>
</options>
</var>
</extra_vars>
</addon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 B

View file

@ -0,0 +1,17 @@
jQuery(function($){
$('button.captchaPlay')
.click(function(){
var swf = document['captcha_audio'] || window['captcha_audio'];
var audio = current_url.setQuery('captcha_action','captchaAudio').setQuery('rand', (new Date).getTime());
if(swf.length > 1) swf = swf[0];
$('input[type=text]#secret_text').focus();
swf.setSoundTarget(audio,'1');
});
$('button.captchaReload')
.click(function(){
$("#captcha_image").attr("src", current_url.setQuery('captcha_action','captchaImage').setQuery('rand', (new Date).getTime()).setQuery('renew',1));
});
});

View file

@ -0,0 +1,31 @@
<?xml version='1.0' encoding='UTF-8'?>
<lang>
<item name="about_captcha">
<value xml:lang="ko"><![CDATA[위 영어 알파벳을 순서대로 입력해 주세요. 대소문자는 구분하지 않습니다.]]></value>
<value xml:lang="en"><![CDATA[Please type the characters you see in the picture above. They are not case-sensitive.]]></value>
<value xml:lang="jp"><![CDATA[アルファベット順に入力してください。大文字、小文字は区別しません。]]></value>
<value xml:lang="zh-CN"><![CDATA[请依次输入图片中的文字,不区分大小写]]></value>
<value xml:lang="zh-TW"><![CDATA[請依序輸入圖片中的文字,不分大小寫。]]></value>
</item>
<item name="captcha_reload">
<value xml:lang="ko"><![CDATA[이미지 새로고침]]></value>
<value xml:lang="en"><![CDATA[Refresh the image]]></value>
<value xml:lang="jp"><![CDATA[リフレッシュ]]></value>
<value xml:lang="zh-CN"><![CDATA[刷新]]></value>
<value xml:lang="zh-TW"><![CDATA[更換]]></value>
</item>
<item name="captcha_play">
<value xml:lang="ko"><![CDATA[음성으로 듣기]]></value>
<value xml:lang="en"><![CDATA[Listen and type the letters you hear.]]></value>
<value xml:lang="jp"><![CDATA[音声]]></value>
<value xml:lang="zh-CN"><![CDATA[播放]]></value>
<value xml:lang="zh-TW"><![CDATA[播放]]></value>
</item>
<item name="captcha_denied">
<value xml:lang="ko"><![CDATA[잘못 입력했습니다]]></value>
<value xml:lang="en"><![CDATA[The characters you entered didn't match the word verification.]]></value>
<value xml:lang="jp"><![CDATA[正しく入力してください。]]></value>
<value xml:lang="zh-CN"><![CDATA[验证码错误]]></value>
<value xml:lang="zh-TW"><![CDATA[輸入錯誤]]></value>
</item>
</lang>

Binary file not shown.